結果

問題 No.816 Beautiful tuples
ユーザー HyadoHyado
提出日時 2019-04-19 21:47:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 166,552 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-24 01:23:45
合計ジャッジ時間 5,291 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int a,b;
    cin >> a >> b;
    for(int c=1;c < a+b;)
    {
        if((a+b)%c == (b+c)%a && (c+a)%b == (a+b)%c && (b+c)%a==0){
            cout << c << endl;
            return 0;
        }
        
        if((a+c)%b==0){
            c+=b;
        }else if((b+c)%a==0){
            c+=a;
        }else{
            c++;
        }

    }
    cout << -1 << endl;
}
0