Title Link: Http://codeforces.com/problemset/problem/712/C
Test instructions
Give you two values A and B (a > B), which means there are two equilateral triangle, the side lengths are A and B, you can transform the triangles with the side length A, each change you can select an edge, and give it a length, of course, you can also make a triangle after the transformation is completed. Ask at least how much The second transformation can transform the equilateral triangle's three-side length from A to B.
Ideas:
The meaning of the topic from the big triangle to the small triangle, here can be replaced by a way, that is, "at least how many times the transformation can be side length from B to a", you can think of, what needs to be done here is to let three sides in the range of change as close as possible to a. That is, for side length (BA, BB, Change range for BA < BB + BC, if BB + BC <= A, then in order to let BA closer to a, you can let BA take BB + BC -1, if BB + BC < A, then BA directly take A is good; Then make the same transformation for the second side BB, and then know that the iteration continues until ba = bb = BC = A, the end of the transformation is good.
Code:
1#include <bits/stdc++.h>2 3 using namespacestd;4typedefLong LongLL;5 6 Const intMAXN =100000;7 intSt, ed, ans =0;8 9 voidSolvintAintBintc) {Ten if(A = = b && a = = c && a = = st)return ; Oneans++; A if(Ans%3==1) St < b + c? A = St:a = B + C-1;//make the first edge as close as possible to St - Else if(Ans%3==2) St < A + c? b = St:b = a + C-1; - ElseSt < A + b? c = St:c = a + B-1; the Solv (A, B, c); - } - - intMain () { + Ios_base::sync_with_stdio (); Cin.tie (); -Cin >> St >>Ed; + Solv (Ed, Ed, ed); Acout << ans <<Endl; at return 0; -}
Codeforces 712C. Memory and De-evolution