結果

問題 No.1200 お菓子配り-3
ユーザー titia
提出日時 2020-08-28 22:06:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 727 bytes
コンパイル時間 395 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 119,796 KB
最終ジャッジ日時 2024-11-14 15:09:47
合計ジャッジ時間 50,235 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26 WA * 2 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
from math import gcd
from math import sqrt

T=int(input())
for tests in range(T):
    ANS=0
    
    X,Y=map(int,input().split())
    if X<Y:
        X,Y=Y,X
    T=X-Y
    xr=int(sqrt(T))+1

    for i in range(1,xr+1):
        if T%i==0 and (X+Y)%(i+2)==0:
            if (T//i)%2==((X+Y)//(i+2))%2 and abs(T//i)<(X+Y)//(i+2):
                ANS+=1
                #print(i+1)
        k=T//i
        if k<=xr:
            continue
        if T%k==0 and (X+Y)%(k+2)==0:
            if (T//k)%2==((X+Y)//(k+2))%2 and abs(T//k)<(X+Y)//(k+2):
                ANS+=1
                #print(k+1)
    sys.stdout.write(str(ANS)+"\n")
    
    
    
0