結果

問題 No.1200 お菓子配り-3
ユーザー chielochielo
提出日時 2020-08-28 22:50:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,195 bytes
コンパイル時間 2,381 ms
コンパイル使用メモリ 198,524 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-09 09:36:55
合計ジャッジ時間 18,429 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 13 ms
4,384 KB
testcase_08 AC 13 ms
4,376 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 12 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 106 ms
4,376 KB
testcase_13 AC 109 ms
4,376 KB
testcase_14 AC 109 ms
4,380 KB
testcase_15 AC 111 ms
4,380 KB
testcase_16 AC 109 ms
4,380 KB
testcase_17 AC 390 ms
4,376 KB
testcase_18 AC 564 ms
4,380 KB
testcase_19 AC 129 ms
4,380 KB
testcase_20 AC 1,084 ms
4,380 KB
testcase_21 AC 1,081 ms
4,380 KB
testcase_22 AC 1,279 ms
4,380 KB
testcase_23 AC 1,087 ms
4,376 KB
testcase_24 AC 1,065 ms
4,380 KB
testcase_25 AC 1,076 ms
4,376 KB
testcase_26 AC 1,079 ms
4,380 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 845 ms
4,384 KB
testcase_29 AC 2,382 ms
4,380 KB
testcase_30 AC 2,381 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;
ll x, y;

void subsolve() {
    ll ans = 0;
    for(int i = 1; i * i <= x; ++i) {
        if(i * i > x)
            break;
        if(x % i)
            continue;
        if(x / i > 1)
            ans += 1;
        if(x != i * i && x / (x / i) > 1)
            ans += 1;
    }
    ans += x;
    printf("%lld\n", ans);
}

void solve() {
    scanf("%lld%lld", &x, &y);
    if(x == y) {
        subsolve();
        return;
    }
    if(x < y)
        std::swap(x, y);
    ll ans = 0;
    auto check = [&](ll a) {
        if(a >= 2 && (x + y) % (a + 1) == 0 && (x - y) % (a - 1) == 0) {
            ll bpc = (x + y) / (a + 1);
            ll bmc = (x - y) / (a - 1);
            ll b = (bpc + bmc) / 2;
            ll c = x - a * b;
            if(b > 0 && c > 0 && a * c + b == y)
                ans += 1;
        }
    };
    for(ll u = 1; u * u <= x - y; ++u) {
        if((x - y) % u)
            continue;
        check(u + 1);
        if((x - y) != u * u)
            check((x - y) / u + 1);
    }
    printf("%lld\n", ans);
}

int main() {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; ++i) {
        solve();
    }
    return 0;
}
0