結果
問題 |
No.816 Beautiful tuples
|
ユーザー |
|
提出日時 | 2020-04-18 18:27:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 455 bytes |
コンパイル時間 | 2,292 ms |
コンパイル使用メモリ | 197,612 KB |
最終ジャッジ日時 | 2025-01-09 21:14:12 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 4 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; vector<long long> divisors(long long a){ vector<long long> res; for(long long i=1;i*i<=a;i++) if(a%i==0) { res.emplace_back(i); if(i*i<a) res.emplace_back(a/i); } sort(res.begin(),res.end()); return res; } int main(){ int a,b; cin>>a>>b; for(auto c:divisors(a+b)){ if((a+c)%b==0 && (b+c)%a==0) return printf("%lld\n",c),0; } puts("-1"); return 0; }