結果

問題 No.442 和と積
ユーザー hermione17hermione17
提出日時 2016-11-11 22:32:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 3,635 ms
コンパイル使用メモリ 71,792 KB
実行使用メモリ 56,300 KB
最終ジャッジ日時 2023-09-18 06:04:38
合計ジャッジ時間 7,117 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,872 KB
testcase_01 AC 122 ms
55,528 KB
testcase_02 AC 126 ms
55,880 KB
testcase_03 AC 126 ms
55,940 KB
testcase_04 AC 127 ms
55,920 KB
testcase_05 AC 127 ms
55,580 KB
testcase_06 AC 123 ms
55,932 KB
testcase_07 AC 123 ms
55,860 KB
testcase_08 AC 129 ms
56,032 KB
testcase_09 AC 125 ms
55,948 KB
testcase_10 AC 128 ms
55,752 KB
testcase_11 AC 127 ms
55,760 KB
testcase_12 AC 126 ms
55,808 KB
testcase_13 AC 126 ms
55,808 KB
testcase_14 AC 126 ms
55,840 KB
testcase_15 AC 124 ms
56,152 KB
testcase_16 AC 124 ms
56,300 KB
testcase_17 AC 131 ms
55,796 KB
testcase_18 AC 126 ms
55,760 KB
testcase_19 AC 127 ms
55,568 KB
testcase_20 AC 129 ms
56,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintStream;
import java.util.Scanner;


public class Y442 {
	Scanner in = new Scanner(System.in);
	PrintStream out = new PrintStream(System.out);

	Y442() throws Exception {
		long a = in.nextLong();
		long b = in.nextLong();
		
		long sum = a + b;
		long g1 = gcd(sum, a);
		sum /= g1;
		long g2 = gcd(sum, b);
		out.print(g1 * g2);				
	}
	
	long gcd(long x, long y) {
		while (y > 0) {
			x %= y;
			long t = x; x = y; y = t;
		}
		return x;
	}

	public static void main(String argv[]) throws Exception {
		new Y442();
	}
}
0