結果

問題 No.415 ぴょん
ユーザー samplelpmas
提出日時 2017-04-26 18:33:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 454 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 74,124 KB
実行使用メモリ 54,300 KB
最終ジャッジ日時 2024-11-18 14:53:38
合計ジャッジ時間 6,785 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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