結果

問題 No.1200 お菓子配り-3
ユーザー 37zigen37zigen
提出日時 2020-08-29 10:53:30
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 703 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,296 KB
実行使用メモリ 82,952 KB
最終ジャッジ日時 2024-04-27 01:00:48
合計ジャッジ時間 34,919 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,608 KB
testcase_01 AC 35 ms
58,356 KB
testcase_02 AC 40 ms
59,100 KB
testcase_03 AC 40 ms
59,960 KB
testcase_04 AC 42 ms
58,852 KB
testcase_05 AC 43 ms
59,280 KB
testcase_06 AC 42 ms
60,276 KB
testcase_07 AC 73 ms
62,540 KB
testcase_08 AC 76 ms
63,724 KB
testcase_09 AC 70 ms
62,948 KB
testcase_10 AC 70 ms
62,232 KB
testcase_11 AC 71 ms
62,720 KB
testcase_12 AC 326 ms
69,980 KB
testcase_13 AC 336 ms
70,264 KB
testcase_14 AC 342 ms
70,128 KB
testcase_15 AC 351 ms
71,420 KB
testcase_16 AC 346 ms
69,596 KB
testcase_17 AC 1,075 ms
76,224 KB
testcase_18 AC 1,489 ms
76,144 KB
testcase_19 AC 385 ms
70,412 KB
testcase_20 AC 2,824 ms
76,556 KB
testcase_21 AC 2,876 ms
76,064 KB
testcase_22 AC 3,438 ms
76,276 KB
testcase_23 AC 2,868 ms
76,132 KB
testcase_24 AC 2,829 ms
76,132 KB
testcase_25 AC 2,910 ms
76,048 KB
testcase_26 AC 2,793 ms
76,120 KB
testcase_27 AC 32 ms
52,880 KB
testcase_28 TLE -
testcase_29 AC 3,424 ms
76,496 KB
testcase_30 AC 3,523 ms
76,240 KB
testcase_31 AC 32 ms
53,468 KB
testcase_32 AC 33 ms
53,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# X=A*B+C
# Y=A*C+B
# X+Y=(A+1)(B+C)

S=int(input())
for _ in range(S):
    X,Y=map(int,input().split())
    ans=0
    if X==Y:
        ans=X-1
    d=1
    while d*d<=X+Y:
        if (X+Y)%d!=0:
            d+=1
            continue
        divs=[d]
        if (X+Y)//d!=d:
            divs.append((X+Y)//d)
        for div in divs:
            if div<=2:
                continue
            A=div-1
            # B+C=bc
            # X=AB+C
            # X=AB+bc-B
            # B=(X-bc)//(A-1)
            bc=(X+Y)//div
            B=(X-bc)//(A-1)
            C=bc-B
            if X!=A*B+C or Y!=A*C+B or A<=0 or B<=0 or C<=0:
                continue
            ans+=1
        d+=1
    print(ans)
0