結果
| 問題 | No.1200 お菓子配り-3 |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:52:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,566 bytes |
| コンパイル時間 | 351 ms |
| コンパイル使用メモリ | 82,116 KB |
| 実行使用メモリ | 78,624 KB |
| 最終ジャッジ日時 | 2025-04-15 23:54:05 |
| 合計ジャッジ時間 | 21,479 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 WA * 2 |
ソースコード
import sys
import math
def get_divisors(n):
divisors = set()
if n == 0:
return []
for i in range(1, int(math.isqrt(n)) + 1):
if n % i == 0:
divisors.add(i)
divisors.add(n // i)
return sorted(divisors)
def solve():
input = sys.stdin.read().split()
S = int(input[0])
idx = 1
for _ in range(S):
X = int(input[idx])
Y = int(input[idx + 1])
idx += 2
if X == Y:
divisors = get_divisors(X)
count = 0
for d in divisors:
if d >= 3 and X % d == 0:
B = X // d
if B > 0:
count += 1
print(count)
else:
D = X - Y
S_sum = X + Y
abs_D = abs(D)
divisors_D = get_divisors(abs_D)
count = 0
for d1 in divisors_D:
d2 = d1 + 2
if S_sum % d2 != 0:
continue
A = d1 + 1
numerator = A * X - Y
denominator = A * A - 1
if denominator == 0:
continue
if numerator % denominator != 0:
continue
B = numerator // denominator
if B <= 0:
continue
C = X - A * B
if C <= 0:
continue
if Y == A * C + B:
count += 1
print(count)
if __name__ == '__main__':
solve()
lam6er