結果

問題 No.816 Beautiful tuples
ユーザー ouoz1Vouoz1V
提出日時 2019-04-20 18:08:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 1,500 ms
コード長 608 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 61,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 19:32:47
合計ジャッジ時間 1,501 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

int main(){
    long long int A,B;
    vector<long long int > div;

    cin>>A>>B;

    for(int i=1; i*i<=A+B; i++){
        if((A+B)%i==0){
            div.push_back(i);
            if(i*i!=A+B){
                div.push_back((A+B)/i);
            }
        }
    }
    for(int i=0; i<div.size(); i++){
        long long int C=div[i];
        if(A!=B && A!=C && B!=C){
            if((A+B)%C==0 && (A+C)%B==0 && (B+C)%A==0){
                cout<<C<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}
0