結果

問題 No.816 Beautiful tuples
ユーザー ttttanttttan
提出日時 2019-04-19 21:37:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 165,356 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-24 00:14:08
合計ジャッジ時間 2,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b;cin>>a>>b;
    ll u=a+b;
    vector<ll> v;
    for(ll i=1;i*i<=u;i++){
        if(u%i==0){
            v.push_back(i);
            v.push_back(u/i);
        }
        
    }
    sort(v.begin(),v.end());
    for(ll i=0;i<v.size();i++){
        if((v[i]+a)%b==0&&(v[i]+b)%a==0&&(a+b)%v[i]==0){
            cout<<v[i]<<endl;
            return 0;
        }
    }
    
    cout<<-1<<endl;
}
0