結果

問題 No.415 ぴょん
ユーザー atkrymatkrym
提出日時 2016-10-31 22:43:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 482 bytes
コンパイル時間 4,965 ms
コンパイル使用メモリ 74,176 KB
実行使用メモリ 54,364 KB
最終ジャッジ日時 2024-04-29 11:46:17
合計ジャッジ時間 6,214 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
53,960 KB
testcase_01 AC 125 ms
54,144 KB
testcase_02 AC 122 ms
54,140 KB
testcase_03 AC 122 ms
53,724 KB
testcase_04 AC 119 ms
54,036 KB
testcase_05 AC 116 ms
53,720 KB
testcase_06 AC 121 ms
53,756 KB
testcase_07 AC 126 ms
54,028 KB
testcase_08 AC 122 ms
53,624 KB
testcase_09 AC 120 ms
53,912 KB
testcase_10 AC 125 ms
54,084 KB
testcase_11 AC 120 ms
53,868 KB
testcase_12 AC 122 ms
53,988 KB
testcase_13 AC 118 ms
53,832 KB
testcase_14 AC 127 ms
53,852 KB
testcase_15 AC 127 ms
54,176 KB
testcase_16 AC 110 ms
52,696 KB
testcase_17 AC 126 ms
54,204 KB
testcase_18 AC 124 ms
53,880 KB
testcase_19 AC 124 ms
53,720 KB
testcase_20 AC 115 ms
53,964 KB
testcase_21 AC 121 ms
53,864 KB
testcase_22 AC 114 ms
53,520 KB
testcase_23 AC 127 ms
54,364 KB
testcase_24 AC 116 ms
52,728 KB
testcase_25 AC 121 ms
54,036 KB
testcase_26 AC 120 ms
54,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        long n = sc.nextLong();
        long d = sc.nextLong();
        long m = gcd(n,d);

        System.out.println(n/m-1);
    }
    
    public static long gcd(long a, long b) {
        long tmp;
        while (b!=0) {
            tmp = a%b;
            a = b;
            b = tmp;
        }
        return a;
    }
}
0