結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-08-28 22:10:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,206 bytes |
| コンパイル時間 | 349 ms |
| コンパイル使用メモリ | 82,592 KB |
| 実行使用メモリ | 76,696 KB |
| 最終ジャッジ日時 | 2024-11-14 15:22:59 |
| 合計ジャッジ時間 | 23,357 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 WA * 3 |
ソースコード
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:
ans = x - 1
for d in range(3, x+1):
if d * d > x:
break
if x % 3 == 0:
ans += 2
if d * d == x:
ans -= 1
if x%2 == 0:
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