結果

問題 No.442 和と積
ユーザー htensaihtensai
提出日時 2019-11-19 12:52:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 74,092 KB
実行使用メモリ 54,548 KB
最終ジャッジ日時 2024-04-14 09:25:06
合計ジャッジ時間 6,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 140 ms
54,368 KB
testcase_02 AC 134 ms
54,264 KB
testcase_03 AC 134 ms
54,444 KB
testcase_04 WA -
testcase_05 AC 134 ms
54,404 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 135 ms
54,264 KB
testcase_10 WA -
testcase_11 AC 134 ms
54,188 KB
testcase_12 AC 137 ms
54,112 KB
testcase_13 AC 137 ms
54,024 KB
testcase_14 AC 141 ms
54,296 KB
testcase_15 AC 140 ms
54,104 KB
testcase_16 AC 136 ms
54,200 KB
testcase_17 AC 136 ms
54,196 KB
testcase_18 WA -
testcase_19 AC 135 ms
54,076 KB
testcase_20 AC 137 ms
54,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = a + b;
		long gcdA = gcd(a, c);
		long gcdB = gcd(b, c);
		long ans = gcdA / gcd(gcdA, gcdB) * gcdB;
		System.out.println(ans);
	}
	
	static long gcd(long a, long b) {
	    if (a % b == 0) {
	        return b;
	    } else {
	        return gcd(b, a % b);
	    }
	}
}
0