結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
developmaso
|
| 提出日時 | 2019-04-20 14:11:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,555 bytes |
| コンパイル時間 | 1,493 ms |
| コンパイル使用メモリ | 167,328 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-10-01 07:02:57 |
| 合計ジャッジ時間 | 2,068 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 8 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
ll A, B;
ll AB;
bool IsOk(ll c) {
if (AB % c != 0) return false;
if (A == c || B == c) return false;
if ((A + c) % B != 0 || (B + c) % A != 0) return false;
return true;
}
void _main() {
cin >> A >> B;
AB = A + B;
ll ans = -1;
for (ll i=1; i*i<=AB; i++) {
if (IsOk(i)) {
ans = i;
break;
}
}
cout << ans << endl;
}
developmaso