結果
問題 | No.141 魔法少女コバ |
ユーザー | tenten |
提出日時 | 2023-07-27 13:21:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 54 ms / 5,000 ms |
コード長 | 2,032 bytes |
コンパイル時間 | 2,299 ms |
コンパイル使用メモリ | 83,916 KB |
実行使用メモリ | 50,432 KB |
最終ジャッジ日時 | 2024-10-04 08:32:53 |
合計ジャッジ時間 | 9,041 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
49,916 KB |
testcase_01 | AC | 48 ms
49,740 KB |
testcase_02 | AC | 48 ms
50,196 KB |
testcase_03 | AC | 48 ms
49,832 KB |
testcase_04 | AC | 48 ms
49,852 KB |
testcase_05 | AC | 47 ms
50,092 KB |
testcase_06 | AC | 48 ms
49,880 KB |
testcase_07 | AC | 50 ms
50,348 KB |
testcase_08 | AC | 54 ms
50,268 KB |
testcase_09 | AC | 47 ms
50,052 KB |
testcase_10 | AC | 48 ms
50,004 KB |
testcase_11 | AC | 49 ms
49,992 KB |
testcase_12 | AC | 50 ms
50,092 KB |
testcase_13 | AC | 48 ms
50,208 KB |
testcase_14 | AC | 47 ms
50,076 KB |
testcase_15 | AC | 47 ms
50,408 KB |
testcase_16 | AC | 49 ms
49,576 KB |
testcase_17 | AC | 49 ms
49,960 KB |
testcase_18 | AC | 48 ms
50,132 KB |
testcase_19 | AC | 50 ms
50,336 KB |
testcase_20 | AC | 50 ms
50,096 KB |
testcase_21 | AC | 50 ms
49,916 KB |
testcase_22 | AC | 50 ms
50,232 KB |
testcase_23 | AC | 51 ms
49,704 KB |
testcase_24 | AC | 54 ms
50,096 KB |
testcase_25 | AC | 54 ms
50,368 KB |
testcase_26 | AC | 52 ms
50,080 KB |
testcase_27 | AC | 50 ms
49,908 KB |
testcase_28 | AC | 48 ms
50,184 KB |
testcase_29 | AC | 48 ms
50,116 KB |
testcase_30 | AC | 47 ms
50,172 KB |
testcase_31 | AC | 46 ms
50,324 KB |
testcase_32 | AC | 47 ms
50,200 KB |
testcase_33 | AC | 47 ms
49,976 KB |
testcase_34 | AC | 47 ms
50,080 KB |
testcase_35 | AC | 48 ms
50,320 KB |
testcase_36 | AC | 47 ms
49,984 KB |
testcase_37 | AC | 49 ms
50,260 KB |
testcase_38 | AC | 49 ms
49,848 KB |
testcase_39 | AC | 47 ms
49,912 KB |
testcase_40 | AC | 50 ms
50,240 KB |
testcase_41 | AC | 52 ms
50,244 KB |
testcase_42 | AC | 52 ms
49,964 KB |
testcase_43 | AC | 49 ms
49,916 KB |
testcase_44 | AC | 51 ms
49,808 KB |
testcase_45 | AC | 48 ms
50,096 KB |
testcase_46 | AC | 47 ms
50,056 KB |
testcase_47 | AC | 48 ms
50,088 KB |
testcase_48 | AC | 53 ms
49,876 KB |
testcase_49 | AC | 49 ms
50,432 KB |
testcase_50 | AC | 49 ms
49,868 KB |
testcase_51 | AC | 47 ms
49,716 KB |
testcase_52 | AC | 47 ms
50,104 KB |
testcase_53 | AC | 47 ms
49,640 KB |
testcase_54 | AC | 47 ms
49,560 KB |
testcase_55 | AC | 48 ms
49,588 KB |
testcase_56 | AC | 49 ms
50,180 KB |
testcase_57 | AC | 47 ms
49,568 KB |
testcase_58 | AC | 46 ms
49,848 KB |
testcase_59 | AC | 45 ms
49,900 KB |
testcase_60 | AC | 48 ms
50,176 KB |
testcase_61 | AC | 47 ms
50,348 KB |
testcase_62 | AC | 48 ms
49,932 KB |
testcase_63 | AC | 48 ms
50,088 KB |
testcase_64 | AC | 47 ms
50,244 KB |
testcase_65 | AC | 46 ms
50,308 KB |
testcase_66 | AC | 47 ms
49,636 KB |
testcase_67 | AC | 46 ms
50,004 KB |
testcase_68 | AC | 46 ms
49,656 KB |
testcase_69 | AC | 49 ms
49,892 KB |
testcase_70 | AC | 47 ms
49,720 KB |
testcase_71 | AC | 48 ms
50,140 KB |
testcase_72 | AC | 49 ms
50,332 KB |
testcase_73 | AC | 49 ms
50,244 KB |
testcase_74 | AC | 48 ms
50,272 KB |
testcase_75 | AC | 50 ms
49,740 KB |
testcase_76 | AC | 49 ms
50,144 KB |
testcase_77 | AC | 49 ms
50,192 KB |
testcase_78 | AC | 46 ms
50,100 KB |
testcase_79 | AC | 47 ms
50,344 KB |
testcase_80 | AC | 47 ms
49,852 KB |
testcase_81 | AC | 47 ms
50,012 KB |
testcase_82 | AC | 48 ms
49,576 KB |
testcase-evil-0.txt | AC | 47 ms
49,900 KB |
testcase-evil-1.txt | AC | 49 ms
49,936 KB |
testcase-evil-2.txt | AC | 49 ms
49,856 KB |
testcase-evil-3.txt | AC | 49 ms
50,036 KB |
testcase-evil-4.txt | AC | 50 ms
50,156 KB |
testcase-evil-5.txt | AC | 47 ms
50,060 KB |
testcase-evil-6.txt | AC | 47 ms
50,364 KB |
testcase-evil-7.txt | AC | 48 ms
50,208 KB |
testcase-evil-8.txt | AC | 48 ms
49,844 KB |
testcase-evil-9.txt | AC | 47 ms
49,924 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int m = sc.nextInt(); int n = sc.nextInt(); int gcd = getGCD(m, n); m /= gcd; n /= gcd; System.out.println(dfw(m, n)); } static int dfw(int child, int mother) { if (mother == 1) { return child - 1; } else if (child < mother) { return dfw(mother, child) + 1; } else { return dfw(child % mother, mother) + child / mother; } } static int getGCD(int x, int y) { if (y == 0) { return x; } else { return getGCD(y, x % y); } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }