結果

問題 No.1200 お菓子配り-3
ユーザー 👑 KazunKazun
提出日時 2020-08-28 23:08:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 616 bytes
コンパイル時間 2,523 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 129,924 KB
最終ジャッジ日時 2024-04-27 00:39:49
合計ジャッジ時間 43,373 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
129,924 KB
testcase_01 AC 33 ms
57,992 KB
testcase_02 AC 39 ms
58,744 KB
testcase_03 AC 36 ms
58,932 KB
testcase_04 AC 37 ms
58,048 KB
testcase_05 AC 38 ms
59,160 KB
testcase_06 AC 37 ms
59,288 KB
testcase_07 AC 77 ms
61,080 KB
testcase_08 AC 79 ms
61,664 KB
testcase_09 AC 76 ms
61,500 KB
testcase_10 AC 75 ms
61,428 KB
testcase_11 AC 76 ms
62,464 KB
testcase_12 AC 418 ms
74,132 KB
testcase_13 AC 445 ms
74,448 KB
testcase_14 AC 444 ms
74,336 KB
testcase_15 AC 446 ms
73,720 KB
testcase_16 AC 442 ms
74,308 KB
testcase_17 AC 1,453 ms
77,152 KB
testcase_18 AC 2,074 ms
77,384 KB
testcase_19 AC 523 ms
75,972 KB
testcase_20 AC 3,873 ms
77,312 KB
testcase_21 AC 3,890 ms
77,416 KB
testcase_22 TLE -
testcase_23 AC 3,886 ms
77,356 KB
testcase_24 AC 3,877 ms
77,180 KB
testcase_25 AC 3,831 ms
77,424 KB
testcase_26 AC 3,828 ms
77,008 KB
testcase_27 AC 32 ms
52,264 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#約数全部
def Divisors(N):
    N=abs(N)
    L,U=[],[]
    k=1
    while k*k <=N:
        if N%k== 0:
            L.append(k)
            if k!=N//k:
                U.append(N//k)
        k+=1
    return L+U[::-1]
#====================================
S=int(input())
L=[0]*S
for i in range(S):
    X,Y=map(int,input().split())

    P=set(map(lambda x:x-1,Divisors(X+Y)))
    Q=set(map(lambda x:x+1,Divisors(X-Y)))
    R=P&Q

    K=0
    for a in R:
        B=(a*X-Y)//(a*a-1)
        C=(a*Y-X)//(a*a-1)
        K+=(B>0 and C>0  and B*(a*a-1)==a*X-Y and C*(a*a-1)==a*Y-X)

    L[i]=K

print("\n".join(map(str,L)))
0