結果

問題 No.1200 お菓子配り-3
ユーザー chineristACchineristAC
提出日時 2020-08-28 23:02:44
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 994 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-27 00:29:22
合計ジャッジ時間 37,083 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 42 ms
57,088 KB
testcase_02 AC 43 ms
57,984 KB
testcase_03 AC 44 ms
57,216 KB
testcase_04 AC 44 ms
57,344 KB
testcase_05 AC 45 ms
57,344 KB
testcase_06 AC 44 ms
57,728 KB
testcase_07 AC 73 ms
59,904 KB
testcase_08 AC 75 ms
59,648 KB
testcase_09 AC 73 ms
59,776 KB
testcase_10 AC 72 ms
59,904 KB
testcase_11 AC 73 ms
60,416 KB
testcase_12 AC 317 ms
66,816 KB
testcase_13 AC 322 ms
66,432 KB
testcase_14 AC 325 ms
67,840 KB
testcase_15 AC 327 ms
66,432 KB
testcase_16 AC 325 ms
67,584 KB
testcase_17 AC 1,016 ms
71,808 KB
testcase_18 AC 1,434 ms
76,172 KB
testcase_19 AC 379 ms
67,456 KB
testcase_20 AC 2,706 ms
75,796 KB
testcase_21 AC 2,700 ms
75,748 KB
testcase_22 AC 3,190 ms
75,904 KB
testcase_23 AC 2,705 ms
75,764 KB
testcase_24 AC 2,712 ms
75,904 KB
testcase_25 AC 2,718 ms
75,912 KB
testcase_26 AC 2,708 ms
75,904 KB
testcase_27 AC 38 ms
51,968 KB
testcase_28 TLE -
testcase_29 AC 3,290 ms
76,032 KB
testcase_30 AC 3,288 ms
75,844 KB
testcase_31 AC 38 ms
51,712 KB
testcase_32 AC 38 ms
51,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(M):#Mの約数列 O(n^(0.5+e))
    d=[]
    i=1
    while M>=i**2:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    return d

import sys

input= sys.stdin.readline

for _ in range(int(input())):
    x,y = map(int,input().split())
    div = divisors(x+y)
    count = 0
    for d in div:
        if x!=y:
            if d==1 or d==2:
                continue

            if (x+y)%d!=0 or (x-y)%(d-2)!=0:
                continue

            s = (x + y) // d
            t = (x - y) // (d-2)
            if (s + t) % 2 !=0:
                continue
            b = (s + t) // 2
            c = (s - t) // 2

            if b>0 and c>0:
                count += 1

        else:
            if d==1:
                continue
            if d==2:
                s = (x + y) // d
                count += s - 1
            else:
                if ((x+y) // d) %2 ==0:
                    count += 1

    print(count)
0