結果
問題 |
No.816 Beautiful tuples
|
ユーザー |
|
提出日時 | 2019-04-19 21:30:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 823 bytes |
コンパイル時間 | 1,531 ms |
コンパイル使用メモリ | 166,188 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 16:41:28 |
合計ジャッジ時間 | 2,186 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 4 |
ソースコード
#include"bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<< #str << " " str<<endl constexpr int INF = (1 << 30); constexpr ll INFL = (1ll << 60); constexpr ll MOD = 1000000007;// 10^9+7 int main() { ll A, B, C; cin >> A >> B; C = A + B; ll best = INFL; FOR(i, 1, sqrt(C) + 1) { if (C%i == 0) { if ((A + i) % B != 0)goto next; if ((B + i) % A != 0)goto next; best = min(best, i); next:; ll j = C / i; if ((A + j) % B != 0)continue; if ((B + j) % A != 0)continue; best = min(best, j); } } cout << (best == INFL ? -1 : best) << endl; return 0; }