結果

問題 No.415 ぴょん
ユーザー Mcpu3Mcpu3
提出日時 2018-08-28 20:50:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 460 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 71,660 KB
実行使用メモリ 56,288 KB
最終ジャッジ日時 2023-09-25 04:18:58
合計ジャッジ時間 7,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,004 KB
testcase_01 AC 122 ms
55,792 KB
testcase_02 AC 122 ms
53,572 KB
testcase_03 AC 122 ms
55,824 KB
testcase_04 AC 123 ms
55,684 KB
testcase_05 AC 122 ms
56,244 KB
testcase_06 AC 122 ms
55,760 KB
testcase_07 AC 122 ms
55,864 KB
testcase_08 AC 122 ms
55,928 KB
testcase_09 AC 122 ms
55,736 KB
testcase_10 AC 123 ms
56,288 KB
testcase_11 AC 127 ms
56,120 KB
testcase_12 AC 123 ms
55,916 KB
testcase_13 AC 123 ms
56,060 KB
testcase_14 AC 125 ms
56,064 KB
testcase_15 AC 123 ms
56,000 KB
testcase_16 AC 122 ms
55,944 KB
testcase_17 AC 123 ms
56,148 KB
testcase_18 AC 123 ms
55,892 KB
testcase_19 AC 124 ms
55,360 KB
testcase_20 AC 121 ms
55,728 KB
testcase_21 AC 122 ms
56,224 KB
testcase_22 AC 124 ms
55,660 KB
testcase_23 AC 124 ms
55,668 KB
testcase_24 AC 125 ms
55,712 KB
testcase_25 AC 125 ms
55,592 KB
testcase_26 AC 124 ms
56,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	public static long gcd(long x,long y) {
		long r;
		if(y>x) {
			r=x;
			x=y;
			y=r;
		}
		while(y>0) {
			r=x%y;
			x=y;
			y=r;
		}
		return x;
	}
	
	public static long lcm(long x,long y) {
		return x*y/gcd(x,y);
	}
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong(),d=sc.nextLong();
		sc.close();
		System.out.print(lcm(n,d)/d-1);
	}
}
0