結果

問題 No.415 ぴょん
ユーザー Mcpu3
提出日時 2018-08-28 20:50:39
言語 Java
(openjdk 23)
結果
AC  
実行時間 130 ms / 1,000 ms
コード長 460 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 74,192 KB
実行使用メモリ 41,332 KB
最終ジャッジ日時 2024-07-18 03:45:22
合計ジャッジ時間 5,995 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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