結果

問題 No.1200 お菓子配り-3
ユーザー boutarouboutarou
提出日時 2020-08-28 22:47:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 974 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 64,220 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 09:32:15
合計ジャッジ時間 17,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 13 ms
4,376 KB
testcase_08 AC 13 ms
4,380 KB
testcase_09 AC 12 ms
4,380 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 108 ms
4,376 KB
testcase_13 AC 110 ms
4,376 KB
testcase_14 AC 109 ms
4,376 KB
testcase_15 AC 111 ms
4,380 KB
testcase_16 AC 108 ms
4,376 KB
testcase_17 AC 389 ms
4,380 KB
testcase_18 AC 560 ms
4,380 KB
testcase_19 AC 131 ms
4,380 KB
testcase_20 AC 1,084 ms
4,376 KB
testcase_21 AC 1,083 ms
4,380 KB
testcase_22 AC 1,269 ms
4,376 KB
testcase_23 AC 1,072 ms
4,376 KB
testcase_24 AC 1,057 ms
4,376 KB
testcase_25 AC 1,067 ms
4,376 KB
testcase_26 AC 1,082 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 862 ms
4,380 KB
testcase_29 AC 2,360 ms
4,380 KB
testcase_30 AC 2,362 ms
4,376 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