Http://codeforces.com/problemset/problem/317/A
Question: Add two numbers to replace one of them. Ask how many times you want to make two digital clocks at least one> = target number m, number of output times, if not, output-1
A simple question is used to practice JAVA. The code is written a little ................
import java.util.*;public class Main{ static long max(long x , long y){ return x > y ? x : y; } static long solve(long a ,long b ,long c){ long res = 0; while( (a >= c || b >= c) == false){ long sum = a + b; long Max = max(a , b); a = sum; b = Max; res++; } return res; } static long __solve(long a , long b , long c){ long res = (-b + a - 1) / a; long tmp = b + res * a; res += solve(a,tmp,c); return res; } public static void main(String[] args){ Scanner cin = new Scanner(System.in); long a,b,c,res; a = cin.nextLong(); b = cin.nextLong(); c = cin.nextLong(); if(a >= c || b >= c) res = 0; else if(a <= 0 && b <= 0) res = -1; else if(a >= 0 && b >= 0){ res = solve(a,b,c); } else{ long tmp; if(a < b){ tmp = a; a = b; b = tmp; } res = __solve(a,b,c); } System.out.println(res); }}