結果

問題 No.442 和と積
コンテスト
ユーザー hermione17
提出日時 2016-11-11 22:32:53
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 543 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,608 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 41,788 KB
最終ジャッジ日時 2026-03-26 04:54:09
合計ジャッジ時間 4,666 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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