結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
![]() |
提出日時 | 2020-03-04 18:45:50 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 142 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 33,868 KB |
最終ジャッジ日時 | 2024-10-14 00:23:33 |
合計ジャッジ時間 | 4,946 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#!/usr/bin/env python3# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesfrom math import gcd# %%P, Q = map(int, readline().split())N = int(readline())m = map(int, read().split())XY = list(zip(m, m))# %%d = gcd(P, Q)if d == 0:answer = sum(x == y == 0 for x, y in XY)print(answer)exit()P //= dQ //= dis_even = (P + Q) % 2 == 0# %%def check(X, Y, d, is_even):if X % d != 0:return Falseif Y % d != 0:return FalseX //= dY //= dif is_even:return (X + Y) % 2 == 0else:return True# %%answer = sum(check(x, y, d, is_even) for x, y in XY)print(answer)