結果

問題 No.816 Beautiful tuples
ユーザー merom686merom686
提出日時 2019-04-19 21:28:01
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 541 bytes
コンパイル時間 492 ms
実行使用メモリ 6,288 KB
最終ジャッジ日時 2023-03-31 11:22:13
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

void f(ll a, ll b, ll c) {
    if ((a + c) % b == 0 && (c + b) % a == 0) {
        cout << c << endl;
        exit(0);
    }
}

int main() {
    ll a, b;
    cin >> a >> b;

    ll c = a + b;

    for (ll i = 1; i * i <= c; i++) {
        if (c % i == 0) {
            f(a, b, i);
            f(a, b, c / i);
        }
    }

    cout << -1 << endl;

    return 0;
}
0