結果

問題 No.1200 お菓子配り-3
ユーザー boutarouboutarou
提出日時 2020-08-28 22:47:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 974 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 64,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 00:05:53
合計ジャッジ時間 17,178 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 14 ms
6,940 KB
testcase_08 AC 14 ms
6,940 KB
testcase_09 AC 13 ms
6,944 KB
testcase_10 AC 13 ms
6,944 KB
testcase_11 AC 12 ms
6,940 KB
testcase_12 AC 110 ms
6,944 KB
testcase_13 AC 112 ms
6,940 KB
testcase_14 AC 112 ms
6,940 KB
testcase_15 AC 115 ms
6,944 KB
testcase_16 AC 112 ms
6,944 KB
testcase_17 AC 402 ms
6,944 KB
testcase_18 AC 579 ms
6,944 KB
testcase_19 AC 133 ms
6,940 KB
testcase_20 AC 1,119 ms
6,940 KB
testcase_21 AC 1,121 ms
6,944 KB
testcase_22 AC 1,319 ms
6,944 KB
testcase_23 AC 1,124 ms
6,940 KB
testcase_24 AC 1,098 ms
6,944 KB
testcase_25 AC 1,109 ms
6,940 KB
testcase_26 AC 1,112 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 882 ms
6,940 KB
testcase_29 AC 2,445 ms
6,940 KB
testcase_30 AC 2,453 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
using ll = long long;

bool f(ll x, ll y) {
    if (x / y > 0 && x % y == 0) return true;
    else return false;
}

void solve() {
    ll x, y;
    cin >> x >> y;
    if (x < y) swap(x, y);
    ll cnt = 0;
    for (ll i = 1; i * i <= x - y; i++) {
        if ((x - y) % i == 0) {
            {
                ll a = i + 1;
                ll div = (a + 1) * (a - 1);
                ll b = a * x - y, c = a * y - x;
                if (f(b, div) && f(c, div)) {
                    cnt++;
                }
            }
            {
                ll a = (x - y) / i + 1;
                ll div = (a + 1) * (a - 1);
                ll b = a * x - y, c = a * y - x;
                if (f(b, div) && f(c, div)) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

int main() {
    ll t;
    cin >> t;
    rep(i, t) solve();
    return 0;
}
0