結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-08-15 02:08:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,500 ms |
| コード長 | 789 bytes |
| コンパイル時間 | 1,709 ms |
| コンパイル使用メモリ | 172,560 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 17:04:06 |
| 合計ジャッジ時間 | 2,524 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repe(i,a)for(auto &i:a)
void in(){} template<typename Head,typename... Tail> void in(Head&& head,Tail&&... tail){cin>>head;in(forward<Tail>(tail)...);}
vector<ll> divisor(ll n){
vector<ll> res;
for(ll i=1;i*i<=n;i++){
if(n%i==0){
res.push_back(i);
if(i!=n/i) res.push_back(n/i);
}
}
sort(res.begin(),res.end());
return res;
}
int main(){
cin.tie(nullptr);ios_base::sync_with_stdio(false);
ll a,b;
in(a,b);
auto ed=divisor(a+b);
repe(c,ed){
if(a==c)continue;
if(b==c)continue;
if((a+c)%b!=0)continue;
if((b+c)%a!=0)continue;
cout<<c<<endl;
return 0;
}
cout<<-1<<endl;
}
mag