結果

問題 No.1200 お菓子配り-3
ユーザー chineristACchineristAC
提出日時 2020-08-28 21:42:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,032 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,056 KB
最終ジャッジ日時 2024-04-26 22:40:13
合計ジャッジ時間 34,785 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
57,344 KB
testcase_01 AC 44 ms
58,112 KB
testcase_02 AC 49 ms
58,240 KB
testcase_03 AC 48 ms
57,984 KB
testcase_04 AC 48 ms
57,984 KB
testcase_05 AC 49 ms
58,112 KB
testcase_06 AC 49 ms
57,856 KB
testcase_07 AC 81 ms
60,416 KB
testcase_08 AC 84 ms
60,672 KB
testcase_09 AC 81 ms
60,672 KB
testcase_10 AC 80 ms
60,672 KB
testcase_11 AC 82 ms
60,160 KB
testcase_12 AC 369 ms
67,072 KB
testcase_13 AC 374 ms
67,712 KB
testcase_14 AC 376 ms
67,584 KB
testcase_15 AC 375 ms
67,712 KB
testcase_16 AC 369 ms
68,352 KB
testcase_17 AC 1,172 ms
74,496 KB
testcase_18 AC 1,664 ms
76,672 KB
testcase_19 AC 432 ms
68,736 KB
testcase_20 AC 3,114 ms
76,288 KB
testcase_21 AC 3,126 ms
76,416 KB
testcase_22 AC 3,696 ms
76,544 KB
testcase_23 AC 3,124 ms
76,928 KB
testcase_24 AC 3,114 ms
76,416 KB
testcase_25 AC 3,110 ms
77,056 KB
testcase_26 AC 3,113 ms
76,288 KB
testcase_27 AC 41 ms
52,096 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(M):#Mの約数列 O(n^(0.5+e))
    import math
    d=[]
    i=1
    while math.sqrt(M)>=i:
        if M%i==0:
            d.append(i)
            if i**2!=M:
                d.append(M//i)
        i=i+1
    d.sort()
    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