結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2021-08-09 00:55:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 608 bytes |
| コンパイル時間 | 3,350 ms |
| コンパイル使用メモリ | 282,304 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 21:12:26 |
| 合計ジャッジ時間 | 3,829 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#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!=d&&(A+d)%B==0&&(B+d)%A==0){
ans=d;
break;
}
}
cout<<ans<<endl;
}
vwxyz