結果

問題 No.442 和と積
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-13 01:39:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 434 bytes
コンパイル時間 4,303 ms
コンパイル使用メモリ 72,128 KB
実行使用メモリ 56,252 KB
最終ジャッジ日時 2023-09-18 07:02:04
合計ジャッジ時間 7,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,652 KB
testcase_01 AC 121 ms
55,776 KB
testcase_02 AC 123 ms
55,700 KB
testcase_03 AC 121 ms
55,900 KB
testcase_04 AC 120 ms
53,720 KB
testcase_05 AC 120 ms
55,516 KB
testcase_06 AC 119 ms
55,616 KB
testcase_07 AC 120 ms
55,472 KB
testcase_08 AC 119 ms
56,228 KB
testcase_09 AC 120 ms
55,588 KB
testcase_10 AC 118 ms
55,788 KB
testcase_11 AC 120 ms
55,636 KB
testcase_12 AC 119 ms
56,252 KB
testcase_13 AC 120 ms
55,700 KB
testcase_14 AC 120 ms
55,752 KB
testcase_15 AC 117 ms
55,744 KB
testcase_16 AC 121 ms
56,248 KB
testcase_17 AC 119 ms
56,036 KB
testcase_18 AC 121 ms
55,952 KB
testcase_19 AC 118 ms
56,244 KB
testcase_20 AC 120 ms
55,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No442{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();

		long sum = a+b;
		long mul = a*b;

		long g1 = gcd(sum, a);
		sum /= g1;
		long g2 = gcd(sum, b);
		
		System.out.println(g1*g2);
	}
	private static long gcd(long x, long y){
		long tmp;
		while((tmp = x%y) != 0){
			x = y;
			y = tmp;
		}
		return y;
	}
}
0