結果

問題 No.1200 お菓子配り-3
ユーザー yuuiyuui
提出日時 2020-08-29 00:41:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,345 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 202,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 00:55:00
合計ジャッジ時間 7,392 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 6 ms
6,944 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 32 ms
6,944 KB
testcase_13 AC 32 ms
6,948 KB
testcase_14 AC 33 ms
6,944 KB
testcase_15 AC 33 ms
6,940 KB
testcase_16 AC 33 ms
6,940 KB
testcase_17 AC 113 ms
6,940 KB
testcase_18 AC 163 ms
6,940 KB
testcase_19 AC 38 ms
6,944 KB
testcase_20 AC 311 ms
6,940 KB
testcase_21 AC 309 ms
6,944 KB
testcase_22 AC 364 ms
6,940 KB
testcase_23 AC 314 ms
6,944 KB
testcase_24 AC 305 ms
6,944 KB
testcase_25 AC 309 ms
6,940 KB
testcase_26 AC 308 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 245 ms
6,940 KB
testcase_29 AC 679 ms
6,944 KB
testcase_30 AC 678 ms
6,944 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void solve() {
    int X, Y;
    cin >> X >> Y;
    if (X == Y) {
        ll ans = X - 1;
        ll t = 2;
        while (t * t <= X) {
            if (X % t == 0) {
                if (t * t == X) {
                    ans++;
                } else {
                    ans += 2;
                }
            }
            t++;
        }
        if (X > 1) {
            ans += 1;
        }
        cout << ans << "\n";
        return;
    }
    if (X < Y) {
        swap(X, Y);
    }

    int PN = X + Y;

    int ans = 0;

    int MN = X - Y;
    int t = 1;
    while (t * t <= MN) {
        if (MN % t == 0) {
            int n = MN / t;
            if (PN % (t + 2) == 0) {
                int target = PN / (t + 2);
                if ((target + n) % 2 == 0 && target > n) {
                    ans++;
                }
            }

            if (n != t && PN % (n + 2) == 0) {
                int target = PN / (n + 2);
                if ((target + t) % 2 == 0 && target > t) {
                    ans++;
                }
            }
        }
        t++;
    }

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S;
    cin >> S;
    for (int i = 0; i < S; i++) {
        solve();
    }

    return 0;
}
0