結果
問題 | No.442 和と積 |
ユーザー |
![]() |
提出日時 | 2016-11-19 01:18:44 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 413 bytes |
コンパイル時間 | 395 ms |
コンパイル使用メモリ | 57,600 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-26 10:35:45 |
合計ジャッジ時間 | 1,010 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 3 |
ソースコード
#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; } cout << ans << endl; return 0; }