結果

問題 No.442 和と積
ユーザー hermione17
提出日時 2016-11-11 22:32:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 543 bytes
コンパイル時間 3,344 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 41,396 KB
最終ジャッジ日時 2024-07-04 22:21:58
合計ジャッジ時間 6,629 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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