結果
| 問題 | No.816 Beautiful tuples |
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2021-08-09 00:51:30 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 596 bytes |
| 記録 | |
| コンパイル時間 | 3,290 ms |
| コンパイル使用メモリ | 282,104 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 21:09:03 |
| 合計ジャッジ時間 | 4,012 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 4 |
ソースコード
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B;
cin>>A>>B;
int ans=-1;
vector<int> divisors(0);
vector<int> divisors_rev(0);
for(int C=1;C*C<=A+B;C++){
if((A+B)%C==0){
divisors.push_back(C);
divisors_rev.push_back((A+B)/C);
}
}
reverse(divisors_rev.begin(),divisors_rev.end());
for(int d:divisors_rev){
divisors.push_back(d);
}
for(int d:divisors){
if((A+d)%B==0&&(B+d)%A==0){
ans=d;
break;
}
}
cout<<ans<<endl;
}
vwxyz