結果

問題 No.816 Beautiful tuples
ユーザー merom686merom686
提出日時 2019-04-19 21:28:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,500 ms
コード長 541 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 73,060 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 23:18:38
合計ジャッジ時間 1,280 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 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