結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-12 21:10:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 526 bytes |
| コンパイル時間 | 2,243 ms |
| コンパイル使用メモリ | 198,872 KB |
| 最終ジャッジ日時 | 2025-01-15 22:17:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int64_t> divisor(int64_t n) {
vector<int64_t> res;
for (int64_t i = 1; i * i <= n; i++) if (n % i == 0) {
res.push_back(i);
if (i * i != n) res.push_back(n / i);
}
sort(res.begin(), res.end());
return res;
}
int main() {
int A, B;
cin >> A >> B;
for (int C : divisor(A + B)) {
if ((A + C) % B == 0 && (B + C) % A == 0) {
cout << C << endl;
return 0;
}
}
cout << -1 << endl;
}