結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
hiroa
|
| 提出日時 | 2019-05-02 16:37:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 556 bytes |
| コンパイル時間 | 1,682 ms |
| コンパイル使用メモリ | 161,152 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 13:32:10 |
| 合計ジャッジ時間 | 2,387 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
vector<int> divisor(int n){
vector<int> res;
for(int i=1;i*i<=n;i++){
if(n%i==0){
res.push_back(i);
if(i!=n/i) res.push_back(n/i);
}
}
return res;
}
int main(){
int A,B;
cin>>A>>B;
vector<int> r=divisor(A+B);
for(int i=0;i<r.size();i++){
if((B+r[i])%A==0 && (r[i]+A)%B==0){
cout<<r[i]<<endl;
return 0;
}
}
cout<<-1<<endl;
}
hiroa