結果
問題 | No.816 Beautiful tuples |
ユーザー |
![]() |
提出日時 | 2019-04-19 21:37:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,500 ms |
コード長 | 415 bytes |
コンパイル時間 | 1,488 ms |
コンパイル使用メモリ | 166,844 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 17:19:15 |
合計ジャッジ時間 | 2,072 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include "bits/stdc++.h" using namespace std; void solve() { long a, b; cin >> a >> b; if (a < b) swap(a, b); for (long i = 1; i * i <= a + b; i++) { if ((a + b) % i) continue; long c = (a + b) / i; if ((a + c) % b == 0 && (a + b) % c == 0 && (b + c) % a == 0) { cout << c << endl; return; } } cout << -1 << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }