|
|
вернуться в форумTime limit exceeded in Java 1.7 test 2 import java.io.BufferedReader; import java.io.InputStreamReader; public class _1131 { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int minut = 0; int a = Integer.parseInt(br.readLine()); int b = Integer.parseInt(br.readLine()); if (b == 1 && a == 1) { System.out.println(b); return; } for (int ok = 1; ok < a; ) { if (ok == 1) { ok++; minut++; } if (ok - b == 0 && a - ok > b) { ok += b; minut++; } else if (ok - b == 0 && a - ok < b) { ok += a - ok; minut++; } if (ok < b && a - ok > b) { ok += ok; minut++; } else if (ok < b && a - ok < b) { ok += a - ok; minut++; } if (ok > b && a - ok > b) { ok += b; minut++; } else if (ok > b && a - ok < b) { ok += a - ok; minut++; } } System.out.println(minut); } } |
|
|