結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
|
提出日時 | 2021-04-28 22:54:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 109 ms / 2,000 ms |
コード長 | 578 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 76,672 KB |
最終ジャッジ日時 | 2024-07-07 21:49:07 |
合計ジャッジ時間 | 5,698 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
from math import gcd P,Q=map(int, input().split()) if P>Q: P,Q=Q,P g=gcd(P,Q) N=int(input()) cnt=0 if P!=0 and Q!=0: P//=g Q//=g for _ in range(N): x,y=map(int, input().split()) if x%g==0 and y%g==0: x//=g y//=g if (x+y)%2==0 or P*Q%2==0: cnt+=1 elif P==0 and Q!=0: for _ in range(N): x,y=map(int, input().split()) if x%Q==0 and y%Q==0: cnt+=1 else: for _ in range(N): x,y=map(int, input().split()) if x==0 and y==0: cnt+=1 print(cnt)