結果
| 問題 | No.1200 お菓子配り-3 |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-08-13 02:55:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 3,115 ms / 4,000 ms |
| コード長 | 1,021 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 77,160 KB |
| 最終ジャッジ日時 | 2024-08-13 02:55:26 |
| 合計ジャッジ時間 | 24,561 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
import sys
input = sys.stdin.readline
T=int(input())
for tests in range(T):
X,Y=map(int,input().split())
if X==Y:
xr=round(X**(1/2))
LIST=[]
for i in range(1,xr+1):
if X%i==0:
LIST.append(i)
if X//i>i:
LIST.append(X//i)
ANS=X-1
for l in LIST:
A=l-1
if A==1:
continue
else:
B=X//(A+1)
if A>0 and B>0:
ANS+=1
print(ANS)
continue
if X<Y:
X,Y=Y,X
xr=round((X-Y)**(1/2))
LIST=[]
for i in range(1,xr+1):
if (X-Y)%i==0:
LIST.append(i)
if (X-Y)//i>i:
LIST.append((X-Y)//i)
ANS=0
for l in LIST:
A=l+1
if A>0 and (X+Y)%(A+1)==0:
k=(X-Y)//(A-1)
l=(X+Y)//(A+1)
if (k+l)%2==0 and k+l>0 and (l-k)%2==0 and l-k>0:
ANS+=1
print(ANS)
titia