結果

問題 No.442 和と積
ユーザー hotpepsi
提出日時 2016-11-19 01:24:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 57,884 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-26 10:46:03
合計ジャッジ時間 1,086 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef long long LL;

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }

int main(int argc, char *argv[]) {
	LL a, b;
	cin >> a >> b;
	LL ab = a + b, ga = gcd(a, ab), gb = gcd(b, ab), g = gcd(ga, gb);
	LL ans = (ga / g) * gb;
	ab /= g;
	if ((ab % g) == 0) {
		ans *= g;
	} else if ((g % ab) == 0) {
		ans *= ab;
	}
	cout << ans << endl;
	return 0;
}
0