結果

問題 No.141 魔法少女コバ
ユーザー tentententen
提出日時 2023-04-14 12:52:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,161 ms / 5,000 ms
コード長 1,985 bytes
コンパイル時間 2,332 ms
コンパイル使用メモリ 87,872 KB
実行使用メモリ 37,912 KB
最終ジャッジ日時 2024-04-18 11:53:44
合計ジャッジ時間 14,715 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,668 KB
testcase_01 AC 1,161 ms
37,912 KB
testcase_02 AC 1,142 ms
37,652 KB
testcase_03 AC 51 ms
36,972 KB
testcase_04 AC 50 ms
37,100 KB
testcase_05 AC 52 ms
36,960 KB
testcase_06 AC 49 ms
37,056 KB
testcase_07 AC 50 ms
36,752 KB
testcase_08 AC 49 ms
37,284 KB
testcase_09 AC 48 ms
36,620 KB
testcase_10 AC 51 ms
37,244 KB
testcase_11 AC 53 ms
37,128 KB
testcase_12 AC 51 ms
37,308 KB
testcase_13 AC 52 ms
36,600 KB
testcase_14 AC 53 ms
37,196 KB
testcase_15 AC 50 ms
37,164 KB
testcase_16 AC 52 ms
36,876 KB
testcase_17 AC 52 ms
37,160 KB
testcase_18 AC 52 ms
37,072 KB
testcase_19 AC 51 ms
36,628 KB
testcase_20 AC 51 ms
36,924 KB
testcase_21 AC 50 ms
37,308 KB
testcase_22 AC 51 ms
37,072 KB
testcase_23 AC 50 ms
36,916 KB
testcase_24 AC 52 ms
37,108 KB
testcase_25 AC 50 ms
37,104 KB
testcase_26 AC 51 ms
37,176 KB
testcase_27 AC 49 ms
36,940 KB
testcase_28 AC 50 ms
36,668 KB
testcase_29 AC 51 ms
36,812 KB
testcase_30 AC 51 ms
37,036 KB
testcase_31 AC 50 ms
37,068 KB
testcase_32 AC 52 ms
37,164 KB
testcase_33 AC 49 ms
36,872 KB
testcase_34 AC 50 ms
37,204 KB
testcase_35 AC 52 ms
36,912 KB
testcase_36 AC 50 ms
36,956 KB
testcase_37 AC 51 ms
37,308 KB
testcase_38 AC 50 ms
37,332 KB
testcase_39 AC 49 ms
37,156 KB
testcase_40 AC 51 ms
36,872 KB
testcase_41 AC 50 ms
36,944 KB
testcase_42 AC 53 ms
37,200 KB
testcase_43 AC 51 ms
36,608 KB
testcase_44 AC 52 ms
37,076 KB
testcase_45 AC 51 ms
37,228 KB
testcase_46 AC 51 ms
37,024 KB
testcase_47 AC 52 ms
37,132 KB
testcase_48 AC 51 ms
37,052 KB
testcase_49 AC 49 ms
36,732 KB
testcase_50 AC 51 ms
36,616 KB
testcase_51 AC 49 ms
37,028 KB
testcase_52 AC 49 ms
37,104 KB
testcase_53 AC 49 ms
36,944 KB
testcase_54 AC 51 ms
37,160 KB
testcase_55 AC 48 ms
37,148 KB
testcase_56 AC 51 ms
36,928 KB
testcase_57 AC 51 ms
36,616 KB
testcase_58 AC 51 ms
37,032 KB
testcase_59 AC 50 ms
37,096 KB
testcase_60 AC 50 ms
37,112 KB
testcase_61 AC 50 ms
36,604 KB
testcase_62 AC 51 ms
37,072 KB
testcase_63 AC 50 ms
37,164 KB
testcase_64 AC 51 ms
37,040 KB
testcase_65 AC 52 ms
36,960 KB
testcase_66 AC 48 ms
37,208 KB
testcase_67 AC 49 ms
37,104 KB
testcase_68 AC 49 ms
37,148 KB
testcase_69 AC 48 ms
36,864 KB
testcase_70 AC 50 ms
36,960 KB
testcase_71 AC 51 ms
37,224 KB
testcase_72 AC 52 ms
37,144 KB
testcase_73 AC 52 ms
36,756 KB
testcase_74 AC 51 ms
36,924 KB
testcase_75 AC 51 ms
36,756 KB
testcase_76 AC 50 ms
37,072 KB
testcase_77 AC 50 ms
36,620 KB
testcase_78 AC 51 ms
37,228 KB
testcase_79 AC 50 ms
37,140 KB
testcase_80 AC 49 ms
37,196 KB
testcase_81 AC 50 ms
37,108 KB
testcase_82 AC 51 ms
37,180 KB
testcase-evil-0.txt AC 591 ms
37,820 KB
testcase-evil-1.txt AC 398 ms
37,692 KB
testcase-evil-2.txt AC 152 ms
39,704 KB
testcase-evil-3.txt AC 239 ms
37,908 KB
testcase-evil-4.txt AC 805 ms
37,524 KB
testcase-evil-5.txt AC 325 ms
37,872 KB
testcase-evil-6.txt AC 203 ms
37,716 KB
testcase-evil-7.txt AC 625 ms
37,772 KB
testcase-evil-8.txt AC 217 ms
37,820 KB
testcase-evil-9.txt AC 103 ms
37,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0