結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-09-04 10:38:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,323 bytes |
| コンパイル時間 | 393 ms |
| コンパイル使用メモリ | 82,764 KB |
| 実行使用メモリ | 76,900 KB |
| 最終ジャッジ日時 | 2024-11-20 23:13:13 |
| 合計ジャッジ時間 | 24,533 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 WA * 1 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
x, y = map(int, input().split())
if x < y:
x, y = y, x
V = x+y
W = x-y
if W == 0:
D = []
for d in range(1, x+1):
if d * d > x:
break
if x % d == 0:
D.append(d)
D.append(x // d)
if D[-1] == D[-2]:
D.pop()
ans = x-1
for d in D:
if d == 1 or d == 2:
continue
ans += 1
print(ans)
continue
ans = 0
for d in range(1, W+1):
if d * d > W:
break
if W%d != 0:
continue
if d*d != W:
D = (d, W//d)
else:
D = (d, )
for dd in D:
if V % (dd+2) != 0:
continue
b_c = W // dd
bc = V // (dd+2)
if (b_c - bc)%2 == 1:
continue
if bc < b_c:
continue
ans += 1
print(ans)
if __name__ == '__main__':
main()
tamato