結果

問題 No.1200 お菓子配り-3
ユーザー t33ft33f
提出日時 2020-08-28 23:00:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 699 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 64,884 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-27 00:22:35
合計ジャッジ時間 16,932 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 14 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 14 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 116 ms
5,376 KB
testcase_13 AC 119 ms
5,376 KB
testcase_14 AC 120 ms
5,376 KB
testcase_15 AC 118 ms
5,376 KB
testcase_16 AC 118 ms
5,376 KB
testcase_17 AC 420 ms
5,376 KB
testcase_18 AC 610 ms
5,376 KB
testcase_19 AC 141 ms
5,376 KB
testcase_20 AC 1,162 ms
5,376 KB
testcase_21 AC 1,172 ms
5,376 KB
testcase_22 AC 1,386 ms
5,376 KB
testcase_23 AC 1,166 ms
5,376 KB
testcase_24 AC 1,150 ms
5,376 KB
testcase_25 AC 1,157 ms
5,376 KB
testcase_26 AC 1,165 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 1,919 ms
5,376 KB
testcase_29 AC 1,425 ms
5,376 KB
testcase_30 AC 1,426 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

bool check(int x, int y, int d) {
    bool ret = (x + y) % d == 0 && (x - y) % (d - 2) == 0 &&
        (x + y) / d % 2 == (x - y) / (d - 2) % 2;
    if (ret) {
        int sum = (x + y) / d, diff = (x - y) / (d - 2);
        if (sum > diff) return true;
    }
    return false;
}

int main() {
    int s; cin >> s;
    while (s--) {
        int x, y; cin >> x >> y;
        if (x < y) swap(x, y);
        long long ans = 0;
        if (x == y) ans += x - 1;
        for (int d = 3; d * d <= x + y; d++) {
            if (check(x, y, d)) ans++;
            if (d * d < x + y && check(x, y, (x + y) / d)) ans++;
        }
        cout << ans << endl;
    }
}
0