結果

問題 No.415 ぴょん
ユーザー samplelpmassamplelpmas
提出日時 2017-04-26 18:33:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 454 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 74,488 KB
実行使用メモリ 41,588 KB
最終ジャッジ日時 2024-04-29 11:48:50
合計ジャッジ時間 5,893 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,236 KB
testcase_01 AC 125 ms
41,560 KB
testcase_02 AC 124 ms
41,344 KB
testcase_03 AC 125 ms
41,272 KB
testcase_04 AC 126 ms
41,208 KB
testcase_05 AC 123 ms
41,240 KB
testcase_06 AC 118 ms
41,544 KB
testcase_07 AC 108 ms
41,248 KB
testcase_08 AC 112 ms
41,444 KB
testcase_09 AC 112 ms
41,568 KB
testcase_10 AC 104 ms
41,348 KB
testcase_11 AC 125 ms
41,104 KB
testcase_12 AC 124 ms
41,512 KB
testcase_13 AC 126 ms
41,444 KB
testcase_14 AC 120 ms
41,380 KB
testcase_15 AC 118 ms
41,588 KB
testcase_16 AC 112 ms
41,336 KB
testcase_17 AC 108 ms
41,416 KB
testcase_18 AC 126 ms
41,236 KB
testcase_19 AC 111 ms
41,192 KB
testcase_20 AC 122 ms
41,068 KB
testcase_21 AC 117 ms
41,276 KB
testcase_22 AC 121 ms
41,284 KB
testcase_23 AC 123 ms
41,448 KB
testcase_24 AC 123 ms
41,572 KB
testcase_25 AC 121 ms
41,048 KB
testcase_26 AC 106 ms
41,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long D = sc.nextLong();

        System.out.println(N / gcd(N, D) - 1);

    }

    private static long gcd(long a, long b) {

        while (b > 0) {

            long remainder = a % b;
            a = b;
            b = remainder;

        }

        return a;

    }

}
0