結果
問題 | No.816 Beautiful tuples |
ユーザー |
|
提出日時 | 2019-04-19 21:56:07 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,500 ms |
コード長 | 918 bytes |
コンパイル時間 | 645 ms |
使用メモリ | 3,576 KB |
最終ジャッジ日時 | 2022-11-25 21:51:36 |
合計ジャッジ時間 | 2,178 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
3,576 KB |
testcase_01 | AC | 1 ms
3,416 KB |
testcase_02 | AC | 1 ms
3,512 KB |
testcase_03 | AC | 1 ms
3,508 KB |
testcase_04 | AC | 1 ms
3,544 KB |
testcase_05 | AC | 1 ms
3,508 KB |
testcase_06 | AC | 1 ms
3,556 KB |
testcase_07 | AC | 1 ms
3,536 KB |
testcase_08 | AC | 2 ms
3,436 KB |
testcase_09 | AC | 2 ms
3,472 KB |
testcase_10 | AC | 1 ms
3,548 KB |
testcase_11 | AC | 2 ms
3,552 KB |
testcase_12 | AC | 2 ms
3,488 KB |
testcase_13 | AC | 2 ms
3,384 KB |
testcase_14 | AC | 2 ms
3,372 KB |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <limits> static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208; vector<ll> divisor(ll n){ vector<ll> ret; for(ll i = 1; i * i <= n; i++) { if(n % i == 0) { ret.push_back(i); if(i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return(ret); } int main() { ll a, b; cin >> a >> b; auto v = divisor(a+b); for (auto &&c : v) { if(a == c || b == c) continue; if((a+b)%c == 0 && (b+c)%a == 0 && (c+a)%b == 0){ printf("%lli\n", c); return 0; } } puts("-1"); return 0; }