結果
問題 |
No.816 Beautiful tuples
|
ユーザー |
![]() |
提出日時 | 2025-07-23 00:11:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 687 bytes |
コンパイル時間 | 2,816 ms |
コンパイル使用メモリ | 275,508 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-23 00:11:04 |
合計ジャッジ時間 | 3,639 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); ll a, b; cin >> a >> b; ll x = a + b; auto f = [&](ll c) { if ((a + b) % c != 0) return false; if ((a + c) % b != 0) return false; if ((b + c) % a != 0) return false; return true; }; ll ans = -1; for (ll c = 1; c * c <= x; ++c) { if (f(c)) { if (ans == -1) ans = c; ans = min(ans, c); } if (x % c == 0 && f(x / c)) { if (ans == -1) ans = x / c; ans = min(ans, x / c); } } cout << ans << '\n'; return 0; }