結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
|
提出日時 | 2022-03-02 12:12:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 563 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 76,544 KB |
最終ジャッジ日時 | 2024-07-16 05:55:08 |
合計ジャッジ時間 | 5,069 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
p,q = map(int,input().split()) N = int(input()) def gcd(a,b): if b == 0:return a while True: r =a % b a = b b = r if r == 0:return a ans = 0 d = gcd(p,q) flag = False if d != 0: p //= d q //= d if (p+q) % 2 == 0: flag = True for _ in range(N): x,y = map(int,input().split()) if d == 0: if x == 0 and y == 0:ans += 1 continue if x % d == 0 and y % d == 0: x //= d y //= d if flag: if (x+y)% 2 == 0:ans+= 1 else:ans += 1 print(ans)