結果

問題 No.415 ぴょん
ユーザー GoryudyumaGoryudyuma
提出日時 2017-03-23 21:55:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 569 bytes
コンパイル時間 2,437 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-08-11 20:32:42
合計ジャッジ時間 6,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
53,640 KB
testcase_01 AC 119 ms
55,796 KB
testcase_02 AC 122 ms
56,052 KB
testcase_03 AC 121 ms
55,884 KB
testcase_04 AC 122 ms
56,100 KB
testcase_05 AC 122 ms
55,456 KB
testcase_06 AC 121 ms
55,732 KB
testcase_07 AC 121 ms
55,860 KB
testcase_08 AC 120 ms
55,692 KB
testcase_09 AC 122 ms
56,468 KB
testcase_10 AC 121 ms
55,720 KB
testcase_11 AC 120 ms
55,844 KB
testcase_12 AC 122 ms
55,692 KB
testcase_13 AC 122 ms
56,144 KB
testcase_14 AC 123 ms
56,280 KB
testcase_15 AC 121 ms
55,724 KB
testcase_16 AC 119 ms
56,016 KB
testcase_17 AC 117 ms
55,728 KB
testcase_18 AC 120 ms
55,980 KB
testcase_19 AC 120 ms
55,996 KB
testcase_20 AC 120 ms
57,756 KB
testcase_21 AC 120 ms
55,660 KB
testcase_22 AC 121 ms
56,444 KB
testcase_23 AC 120 ms
55,772 KB
testcase_24 AC 121 ms
56,224 KB
testcase_25 AC 120 ms
55,912 KB
testcase_26 AC 121 ms
56,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long N = sc.nextLong(), D = sc.nextLong();
                        System.out.println(N / gcd(N, D) - 1);
                }
        }
        private static long gcd(long A, long B) {
                if (A < B) {
                        return gcd(B, A);
                }
                if (B == 0) {
                        return A;
                }
                return gcd(B, A%B);
        }
}
0