結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:46:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,318 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 83,016 KB |
実行使用メモリ | 79,168 KB |
最終ジャッジ日時 | 2025-03-26 15:47:38 |
合計ジャッジ時間 | 33,833 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 2 |
ソースコード
import sys import math def get_divisors(n): divisors = set() 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() idx = 0 S = int(input[idx]) idx += 1 for _ in range(S): X = int(input[idx]) Y = int(input[idx + 1]) idx += 2 S_total = X + Y D = abs(X - Y) divisors = get_divisors(S_total) count = 0 for d in divisors: if d < 3: continue temp = d - 2 if D != 0: if temp == 0 or D % temp != 0: continue A = d - 1 denominator = (d - 2) * d numeratorB = A * X - Y if numeratorB <= 0: continue if numeratorB % denominator != 0: continue B = numeratorB // denominator numeratorC = A * Y - X if numeratorC <= 0: continue if numeratorC % denominator != 0: continue C = numeratorC // denominator if B > 0 and C > 0: count += 1 print(count) if __name__ == "__main__": solve()