結果

問題 No.415 ぴょん
ユーザー ym678ym678
提出日時 2016-08-27 22:01:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 338 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 75,364 KB
実行使用メモリ 56,064 KB
最終ジャッジ日時 2024-04-26 07:02:15
合計ジャッジ時間 6,098 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 120 ms
54,404 KB
testcase_02 WA -
testcase_03 AC 125 ms
54,320 KB
testcase_04 WA -
testcase_05 AC 110 ms
52,732 KB
testcase_06 WA -
testcase_07 AC 124 ms
54,076 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 127 ms
56,040 KB
testcase_11 WA -
testcase_12 AC 126 ms
54,164 KB
testcase_13 AC 126 ms
54,072 KB
testcase_14 AC 125 ms
54,432 KB
testcase_15 AC 127 ms
53,756 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 127 ms
54,156 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 127 ms
54,264 KB
testcase_25 AC 133 ms
54,100 KB
testcase_26 AC 116 ms
54,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long D = sc.nextLong();
		System.out.println(N*gcd(N,D)-1);
	}

	public static long gcd(long N, long D){
		while(D != 0){
			long r = N % D;
			N = D;
			D = r;
		}
		return N;
	}
}
0