結果

問題 No.1200 お菓子配り-3
ユーザー tamatotamato
提出日時 2020-08-28 21:44:33
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,152 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,800 KB
最終ジャッジ日時 2024-04-26 22:41:38
合計ジャッジ時間 34,253 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,572 KB
testcase_01 AC 43 ms
57,344 KB
testcase_02 AC 45 ms
57,344 KB
testcase_03 AC 46 ms
57,584 KB
testcase_04 AC 45 ms
57,300 KB
testcase_05 AC 46 ms
57,928 KB
testcase_06 AC 46 ms
57,984 KB
testcase_07 AC 77 ms
59,456 KB
testcase_08 AC 78 ms
59,288 KB
testcase_09 AC 80 ms
59,264 KB
testcase_10 AC 76 ms
59,264 KB
testcase_11 AC 78 ms
59,276 KB
testcase_12 AC 358 ms
68,036 KB
testcase_13 AC 361 ms
67,328 KB
testcase_14 AC 367 ms
68,352 KB
testcase_15 AC 367 ms
67,456 KB
testcase_16 AC 361 ms
67,584 KB
testcase_17 AC 1,142 ms
76,244 KB
testcase_18 AC 1,623 ms
76,672 KB
testcase_19 AC 425 ms
68,520 KB
testcase_20 AC 3,032 ms
76,160 KB
testcase_21 AC 3,102 ms
76,288 KB
testcase_22 AC 3,588 ms
76,160 KB
testcase_23 AC 3,034 ms
76,380 KB
testcase_24 AC 3,035 ms
76,288 KB
testcase_25 AC 3,024 ms
76,332 KB
testcase_26 AC 3,050 ms
76,160 KB
testcase_27 AC 38 ms
52,224 KB
testcase_28 TLE -
testcase_29 AC 3,663 ms
76,800 KB
testcase_30 AC 3,667 ms
76,652 KB
testcase_31 AC 39 ms
53,068 KB
testcase_32 AC 39 ms
52,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    def divisors(n):
        ret = []
        for d in range(1, n+1):
            if d * d > n:
                break
            if n%d == 0:
                ret.append(d)
                ret.append(n//d)
        if ret[-1] == ret[-2]:
            ret.pop()
        return ret

    for _ in range(int(input())):
        x, y = map(int, input().split())
        if x < y:
            x, y = y, x

        xy = x+y
        div = divisors(xy)
        ans = 0
        for d in div:
            a = d - 1
            if a == 0:
                continue
            bc = xy // (a+1)
            if a == 1:
                if x == y:
                    ans += x-1
                    continue
                else:
                    continue
            if (x-y) % (a-1) != 0:
                continue
            b_c = (x-y) // (a-1)
            if bc%2 == b_c%2:
                b = (bc + b_c)//2
                c = (bc - b_c)//2
                if b > 0 and c > 0:
                    ans += 1
        print(ans)


if __name__ == '__main__':
    main()
0