結果
問題 | No.141 魔法少女コバ |
ユーザー | tutuz |
提出日時 | 2018-09-14 21:55:25 |
言語 | Java21 (openjdk 21) |
結果 |
MLE
|
実行時間 | - |
コード長 | 3,380 bytes |
コンパイル時間 | 2,433 ms |
コンパイル使用メモリ | 77,996 KB |
実行使用メモリ | 773,344 KB |
最終ジャッジ日時 | 2024-07-06 10:07:45 |
合計ジャッジ時間 | 24,754 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
37,120 KB |
testcase_01 | MLE | - |
testcase_02 | MLE | - |
testcase_03 | AC | 56 ms
46,600 KB |
testcase_04 | AC | 54 ms
44,424 KB |
testcase_05 | AC | 53 ms
44,420 KB |
testcase_06 | AC | 54 ms
44,360 KB |
testcase_07 | AC | 55 ms
44,408 KB |
testcase_08 | AC | 54 ms
44,028 KB |
testcase_09 | AC | 54 ms
44,424 KB |
testcase_10 | AC | 54 ms
44,028 KB |
testcase_11 | AC | 55 ms
44,304 KB |
testcase_12 | AC | 55 ms
44,208 KB |
testcase_13 | AC | 56 ms
44,424 KB |
testcase_14 | AC | 55 ms
43,980 KB |
testcase_15 | AC | 56 ms
44,032 KB |
testcase_16 | AC | 53 ms
44,208 KB |
testcase_17 | AC | 55 ms
44,356 KB |
testcase_18 | AC | 57 ms
44,336 KB |
testcase_19 | AC | 54 ms
44,284 KB |
testcase_20 | AC | 54 ms
44,156 KB |
testcase_21 | AC | 55 ms
43,740 KB |
testcase_22 | AC | 55 ms
44,276 KB |
testcase_23 | AC | 55 ms
43,896 KB |
testcase_24 | AC | 54 ms
44,332 KB |
testcase_25 | AC | 55 ms
44,128 KB |
testcase_26 | AC | 55 ms
44,204 KB |
testcase_27 | AC | 55 ms
44,284 KB |
testcase_28 | AC | 55 ms
44,252 KB |
testcase_29 | AC | 55 ms
44,276 KB |
testcase_30 | AC | 55 ms
44,580 KB |
testcase_31 | AC | 55 ms
43,900 KB |
testcase_32 | AC | 55 ms
44,016 KB |
testcase_33 | AC | 54 ms
44,432 KB |
testcase_34 | AC | 55 ms
44,228 KB |
testcase_35 | AC | 56 ms
44,576 KB |
testcase_36 | AC | 55 ms
44,448 KB |
testcase_37 | AC | 54 ms
44,276 KB |
testcase_38 | AC | 55 ms
43,776 KB |
testcase_39 | AC | 55 ms
44,220 KB |
testcase_40 | AC | 55 ms
44,576 KB |
testcase_41 | AC | 54 ms
37,304 KB |
testcase_42 | AC | 53 ms
37,116 KB |
testcase_43 | AC | 52 ms
37,196 KB |
testcase_44 | AC | 53 ms
37,236 KB |
testcase_45 | AC | 55 ms
37,264 KB |
testcase_46 | AC | 55 ms
36,884 KB |
testcase_47 | AC | 53 ms
37,236 KB |
testcase_48 | AC | 54 ms
36,760 KB |
testcase_49 | AC | 54 ms
36,984 KB |
testcase_50 | AC | 52 ms
36,984 KB |
testcase_51 | AC | 53 ms
36,828 KB |
testcase_52 | AC | 53 ms
37,120 KB |
testcase_53 | AC | 53 ms
37,292 KB |
testcase_54 | AC | 53 ms
37,088 KB |
testcase_55 | AC | 53 ms
37,024 KB |
testcase_56 | AC | 53 ms
37,156 KB |
testcase_57 | AC | 53 ms
37,156 KB |
testcase_58 | AC | 53 ms
36,860 KB |
testcase_59 | AC | 54 ms
37,136 KB |
testcase_60 | AC | 53 ms
36,724 KB |
testcase_61 | AC | 53 ms
36,964 KB |
testcase_62 | AC | 52 ms
37,056 KB |
testcase_63 | AC | 53 ms
37,136 KB |
testcase_64 | AC | 53 ms
37,076 KB |
testcase_65 | AC | 54 ms
36,884 KB |
testcase_66 | AC | 52 ms
37,324 KB |
testcase_67 | AC | 53 ms
37,160 KB |
testcase_68 | AC | 52 ms
37,076 KB |
testcase_69 | AC | 53 ms
36,760 KB |
testcase_70 | AC | 57 ms
37,120 KB |
testcase_71 | AC | 53 ms
37,220 KB |
testcase_72 | AC | 53 ms
36,984 KB |
testcase_73 | AC | 52 ms
36,748 KB |
testcase_74 | AC | 53 ms
36,872 KB |
testcase_75 | AC | 52 ms
37,024 KB |
testcase_76 | AC | 52 ms
36,984 KB |
testcase_77 | AC | 52 ms
36,924 KB |
testcase_78 | AC | 51 ms
36,736 KB |
testcase_79 | AC | 53 ms
36,884 KB |
testcase_80 | AC | 51 ms
37,192 KB |
testcase_81 | AC | 52 ms
36,752 KB |
testcase_82 | AC | 53 ms
36,952 KB |
testcase-evil-0.txt | MLE | - |
testcase-evil-1.txt | MLE | - |
testcase-evil-2.txt | MLE | - |
testcase-evil-3.txt | MLE | - |
testcase-evil-4.txt | MLE | - |
testcase-evil-5.txt | MLE | - |
testcase-evil-6.txt | MLE | - |
testcase-evil-7.txt | MLE | - |
testcase-evil-8.txt | MLE | - |
testcase-evil-9.txt | MLE | - |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskX solver = new TaskX(); solver.solve(1, in, out); out.close(); } static int INF = 1 << 30; static long LINF = 1L << 55; static int MOD = 1000000007; static int[] mh4 = { 0, -1, 1, 0 }; static int[] mw4 = { -1, 0, 0, 1 }; static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 }; static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 }; static class TaskX { public void solve(int testNumber, InputReader in, PrintWriter out) { long m = in.nextLong(), n = in.nextLong(); long g = gcd(n, m); m /= g; n /= g; long ans = f(m, n, 0, false); out.println(ans); } long f(long bs, long bb, long cnt, boolean isSwap) { long ret = 0; if (bb == bs) { return cnt; } if (bs <= 0) { return 0; } if (isSwap) { ret += f(bs-bb, bb, cnt+1, false); } else { if (bs - bb > 0) { ret += Math.max(f(bs-bb, bb, cnt+1, false), f(bb, bs, cnt+1, true)); } else { ret += f(bb, bs, cnt+1, true); } } return ret; } } public static long gcd(long a, long b) { return (b == 0) ? a : gcd(b, a % b); } static class InputReader { BufferedReader in; StringTokenizer tok; public String nextString() { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine(), " "); } catch (IOException e) { throw new InputMismatchException(); } } return tok.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public double nextDouble() { return Double.parseDouble(nextString()); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[] nextIntArrayDec(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt() - 1; } return res; } public int[] nextIntArray1Index(int n) { int[] res = new int[n + 1]; for (int i = 0; i < n; i++) { res[i + 1] = nextInt(); } return res; } public long[] nextLongArray(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public long[] nextLongArrayDec(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong() - 1; } return res; } public long[] nextLongArray1Index(int n) { long[] res = new long[n + 1]; for (int i = 0; i < n; i++) { res[i + 1] = nextLong(); } return res; } public double[] nextDoubleArray(int n) { double[] res = new double[n]; for (int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } public InputReader(InputStream inputStream) { in = new BufferedReader(new InputStreamReader(inputStream)); tok = new StringTokenizer(""); } } }