結果

問題 No.816 Beautiful tuples
ユーザー sinsincoscossinsincoscos
提出日時 2019-04-19 21:42:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 64,172 KB
実行使用メモリ 7,804 KB
最終ジャッジ日時 2023-10-24 00:52:22
合計ジャッジ時間 5,764 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

int A,B;
int main(){
    cin >> A >> B;
    for(int i=1;i<=A+B;i++){
        if(A!=i && B!=i && (A+B)%i==0){
            if((A+i)%B==0 && (B+i)%A==0){
                cout << i << endl;
                return 0;
            }
        }
    }
    int i = A+B;
    if(A!=i && B!=i && (A+B)%i==0){
        if((A+i)%B==0 && (B+i)%A==0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}
0