結果

問題 No.816 Beautiful tuples
ユーザー mdan16Dmdan16D
提出日時 2019-04-20 01:21:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 951 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 166,988 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:53:36
合計ジャッジ時間 2,181 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int A, B;

int main() {
    cin >> A >> B;
    int result = -1;
    for (int i = 0; (i * A - B) <= A + B; i++) {
        int C = (i * A - B);
        //cout << C << endl;
        if (C == A || C == B || C < 1) {
            continue;
        }
        //cout << C << endl;
        if ((A + C) % B == 0 && (B + C) % A == 0 && (A + B) % C == 0) {
            result = C;
            break;
        }
    }
    cout << result << endl;
}
0