結果
問題 | No.816 Beautiful tuples |
ユーザー |
|
提出日時 | 2020-04-18 18:28:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 1,500 ms |
コード長 | 471 bytes |
コンパイル時間 | 3,001 ms |
コンパイル使用メモリ | 197,352 KB |
最終ジャッジ日時 | 2025-01-09 21:14:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#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!=c && (a+c)%b==0 && (b+c)%a==0) return printf("%lld\n",c),0; } puts("-1"); return 0; }