結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
|
提出日時 | 2016-04-19 18:53:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 355 ms / 2,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-06 22:11:44 |
合計ジャッジ時間 | 8,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#!/usr/bin/env python3import mathp, q = map(int,input().split())n = int(input())if p == 0 and q == 0:zero = Trueelif p == 0 and q == 0:gcd = p + qeven = Truezero = Falseelse:gcd = math.gcd(p, q)even = (p / gcd) % 2 == 0 or (q / gcd) % 2 == 0zero = Falseans = 0for i in range(n):x, y = map(int,input().split())if zero:if x == 0 and y == 0:ans += 1else:if x % gcd == 0 and y % gcd == 0:if even:ans += 1else:if ((x / gcd) + (y / gcd)) % 2 == 0:ans += 1print(ans)