結果

問題 No.415 ぴょん
ユーザー htensaihtensai
提出日時 2020-05-07 16:04:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 455 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 72,028 KB
実行使用メモリ 56,172 KB
最終ジャッジ日時 2023-09-16 07:55:07
合計ジャッジ時間 6,933 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,600 KB
testcase_01 AC 123 ms
55,644 KB
testcase_02 AC 123 ms
55,828 KB
testcase_03 AC 122 ms
55,716 KB
testcase_04 AC 123 ms
55,784 KB
testcase_05 AC 125 ms
55,472 KB
testcase_06 AC 126 ms
55,640 KB
testcase_07 AC 124 ms
55,420 KB
testcase_08 AC 122 ms
55,820 KB
testcase_09 AC 122 ms
56,152 KB
testcase_10 AC 122 ms
55,412 KB
testcase_11 AC 122 ms
55,636 KB
testcase_12 AC 124 ms
55,768 KB
testcase_13 AC 122 ms
55,952 KB
testcase_14 AC 123 ms
55,924 KB
testcase_15 AC 120 ms
55,640 KB
testcase_16 AC 124 ms
55,604 KB
testcase_17 AC 125 ms
55,640 KB
testcase_18 AC 125 ms
55,596 KB
testcase_19 AC 121 ms
55,536 KB
testcase_20 AC 127 ms
56,116 KB
testcase_21 AC 124 ms
56,172 KB
testcase_22 AC 124 ms
55,724 KB
testcase_23 AC 130 ms
55,876 KB
testcase_24 AC 123 ms
55,764 KB
testcase_25 AC 122 ms
55,900 KB
testcase_26 AC 122 ms
55,676 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();
		long lcm = getLCM(n, d);
		System.out.println(lcm / 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