結果

問題 No.816 Beautiful tuples
ユーザー HyadoHyado
提出日時 2019-04-20 00:19:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 3,715 ms
コンパイル使用メモリ 172,148 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 16:52:36
合計ジャッジ時間 2,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second

vector<int> finddivisor(int x){
    vector<int> divisor;
    for(int i=1; i*i<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
        }
    }
    divisor.push_back(x);
    return divisor;
}//整数xの約数が入ったvectorを返すよ(xを含む)  

int main(){
    ll a,b;
    cin >> a >> b;
    vector<int> v=finddivisor(a+b);
    sort(v.begin(),v.end());

    for(int i=0;i < v.size();i++)
    {
        if((b+v.at(i))%a == (v.at(i)+a)%b && (b+v.at(i))%a==0 && v.at(i)!=a && b!=v.at(i)){
            cout << v.at(i) << endl;
            return 0;
        }
    }
        
    cout << -1 << endl;
}
0