結果

問題 No.816 Beautiful tuples
コンテスト
ユーザー hiroa
提出日時 2019-05-02 16:37:06
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 556 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 858 ms
コンパイル使用メモリ 180,388 KB
実行使用メモリ 9,776 KB
最終ジャッジ日時 2026-10-12 19:18:10
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    
}
0