結果
問題 |
No.442 和と積
|
ユーザー |
![]() |
提出日時 | 2016-11-18 01:34:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 441 bytes |
コンパイル時間 | 496 ms |
コンパイル使用メモリ | 57,824 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 03:29:54 |
合計ジャッジ時間 | 1,046 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 8 WA * 10 |
ソースコード
#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, gab = gcd(a, b); LL ans = gcd(ab, (a / gab) * (b / gab)); for (int i = 0; i < 2; ++i) { if ((ab % gab) == 0) { ab /= gab; ans *= gab; } } cout << ans << endl; return 0; }