結果

問題 No.415 ぴょん
ユーザー tentententen
提出日時 2020-10-14 16:28:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 1,000 ms
コード長 448 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 71,272 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-09-28 00:39:17
合計ジャッジ時間 5,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,872 KB
testcase_01 AC 114 ms
55,940 KB
testcase_02 AC 113 ms
56,552 KB
testcase_03 AC 109 ms
55,620 KB
testcase_04 AC 111 ms
55,708 KB
testcase_05 AC 110 ms
56,112 KB
testcase_06 AC 112 ms
56,096 KB
testcase_07 AC 110 ms
56,088 KB
testcase_08 AC 112 ms
56,036 KB
testcase_09 AC 112 ms
55,988 KB
testcase_10 AC 112 ms
56,444 KB
testcase_11 AC 111 ms
55,888 KB
testcase_12 AC 111 ms
55,844 KB
testcase_13 AC 109 ms
53,916 KB
testcase_14 AC 111 ms
55,848 KB
testcase_15 AC 111 ms
56,336 KB
testcase_16 AC 110 ms
56,288 KB
testcase_17 AC 112 ms
55,792 KB
testcase_18 AC 110 ms
55,840 KB
testcase_19 AC 109 ms
55,840 KB
testcase_20 AC 113 ms
56,020 KB
testcase_21 AC 112 ms
55,732 KB
testcase_22 AC 119 ms
55,716 KB
testcase_23 AC 118 ms
56,128 KB
testcase_24 AC 122 ms
55,820 KB
testcase_25 AC 120 ms
55,688 KB
testcase_26 AC 120 ms
55,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int d = sc.nextInt();
    	System.out.println(getLCM(n, d) / d - 1);
	}
	
	static long getLCM(long x, long y) {
	    return x / getGCD(x, y) * y;
	}
	
	static long getGCD(long x, long y) {
	    if (x % y == 0) {
	        return y;
	    } else {
	        return getGCD(y, x % y);
	    }
	}
}
0