結果
問題 | No.141 魔法少女コバ |
ユーザー | tenten |
提出日時 | 2023-04-14 12:52:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,199 ms / 5,000 ms |
コード長 | 1,985 bytes |
コンパイル時間 | 3,145 ms |
コンパイル使用メモリ | 91,148 KB |
実行使用メモリ | 37,668 KB |
最終ジャッジ日時 | 2024-10-10 05:05:55 |
合計ジャッジ時間 | 15,995 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
36,944 KB |
testcase_01 | AC | 1,199 ms
37,668 KB |
testcase_02 | AC | 1,199 ms
37,664 KB |
testcase_03 | AC | 53 ms
37,016 KB |
testcase_04 | AC | 52 ms
37,036 KB |
testcase_05 | AC | 53 ms
37,056 KB |
testcase_06 | AC | 53 ms
37,096 KB |
testcase_07 | AC | 53 ms
37,100 KB |
testcase_08 | AC | 56 ms
36,964 KB |
testcase_09 | AC | 52 ms
37,172 KB |
testcase_10 | AC | 53 ms
37,288 KB |
testcase_11 | AC | 54 ms
37,180 KB |
testcase_12 | AC | 52 ms
36,744 KB |
testcase_13 | AC | 54 ms
37,036 KB |
testcase_14 | AC | 55 ms
36,768 KB |
testcase_15 | AC | 56 ms
36,952 KB |
testcase_16 | AC | 54 ms
37,092 KB |
testcase_17 | AC | 52 ms
36,792 KB |
testcase_18 | AC | 54 ms
36,840 KB |
testcase_19 | AC | 54 ms
36,772 KB |
testcase_20 | AC | 53 ms
37,140 KB |
testcase_21 | AC | 55 ms
37,004 KB |
testcase_22 | AC | 56 ms
36,980 KB |
testcase_23 | AC | 52 ms
37,036 KB |
testcase_24 | AC | 53 ms
36,768 KB |
testcase_25 | AC | 52 ms
37,048 KB |
testcase_26 | AC | 53 ms
37,024 KB |
testcase_27 | AC | 53 ms
37,132 KB |
testcase_28 | AC | 53 ms
36,956 KB |
testcase_29 | AC | 52 ms
36,760 KB |
testcase_30 | AC | 52 ms
37,164 KB |
testcase_31 | AC | 52 ms
36,944 KB |
testcase_32 | AC | 53 ms
36,960 KB |
testcase_33 | AC | 54 ms
37,088 KB |
testcase_34 | AC | 53 ms
36,756 KB |
testcase_35 | AC | 53 ms
36,736 KB |
testcase_36 | AC | 53 ms
36,960 KB |
testcase_37 | AC | 52 ms
36,920 KB |
testcase_38 | AC | 52 ms
36,920 KB |
testcase_39 | AC | 52 ms
37,120 KB |
testcase_40 | AC | 53 ms
37,024 KB |
testcase_41 | AC | 53 ms
36,924 KB |
testcase_42 | AC | 55 ms
37,192 KB |
testcase_43 | AC | 54 ms
37,156 KB |
testcase_44 | AC | 52 ms
36,980 KB |
testcase_45 | AC | 55 ms
37,284 KB |
testcase_46 | AC | 54 ms
36,788 KB |
testcase_47 | AC | 55 ms
37,028 KB |
testcase_48 | AC | 54 ms
36,940 KB |
testcase_49 | AC | 53 ms
36,968 KB |
testcase_50 | AC | 53 ms
36,896 KB |
testcase_51 | AC | 53 ms
37,104 KB |
testcase_52 | AC | 54 ms
37,132 KB |
testcase_53 | AC | 53 ms
36,752 KB |
testcase_54 | AC | 52 ms
36,900 KB |
testcase_55 | AC | 53 ms
37,248 KB |
testcase_56 | AC | 55 ms
37,136 KB |
testcase_57 | AC | 55 ms
36,636 KB |
testcase_58 | AC | 53 ms
37,020 KB |
testcase_59 | AC | 53 ms
36,884 KB |
testcase_60 | AC | 53 ms
37,184 KB |
testcase_61 | AC | 54 ms
37,004 KB |
testcase_62 | AC | 52 ms
36,952 KB |
testcase_63 | AC | 53 ms
37,076 KB |
testcase_64 | AC | 53 ms
36,764 KB |
testcase_65 | AC | 52 ms
36,956 KB |
testcase_66 | AC | 52 ms
36,788 KB |
testcase_67 | AC | 53 ms
37,192 KB |
testcase_68 | AC | 52 ms
36,660 KB |
testcase_69 | AC | 52 ms
36,920 KB |
testcase_70 | AC | 55 ms
37,116 KB |
testcase_71 | AC | 52 ms
37,284 KB |
testcase_72 | AC | 54 ms
36,956 KB |
testcase_73 | AC | 55 ms
36,752 KB |
testcase_74 | AC | 52 ms
37,024 KB |
testcase_75 | AC | 54 ms
37,024 KB |
testcase_76 | AC | 54 ms
37,112 KB |
testcase_77 | AC | 55 ms
36,960 KB |
testcase_78 | AC | 56 ms
37,100 KB |
testcase_79 | AC | 54 ms
37,140 KB |
testcase_80 | AC | 53 ms
36,964 KB |
testcase_81 | AC | 52 ms
37,000 KB |
testcase_82 | AC | 53 ms
37,072 KB |
testcase-evil-0.txt | AC | 618 ms
37,688 KB |
testcase-evil-1.txt | AC | 409 ms
37,932 KB |
testcase-evil-2.txt | AC | 157 ms
37,828 KB |
testcase-evil-3.txt | AC | 252 ms
37,604 KB |
testcase-evil-4.txt | AC | 848 ms
37,688 KB |
testcase-evil-5.txt | AC | 346 ms
37,404 KB |
testcase-evil-6.txt | AC | 211 ms
37,756 KB |
testcase-evil-7.txt | AC | 651 ms
37,732 KB |
testcase-evil-8.txt | AC | 225 ms
37,688 KB |
testcase-evil-9.txt | AC | 107 ms
37,784 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 a = sc.nextInt(); int b = sc.nextInt(); int gcd = getGCD(a, b); a /= gcd; b /= gcd; int count = 0; while (a != 1 || b != 1) { if (a < b) { int tmp = a; a = b; b = tmp; } else { a -= b; } count++; } System.out.println(count); } 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(); } }