結果
問題 | No.849 yuki国の分割統治 |
ユーザー |
![]() |
提出日時 | 2021-09-20 09:13:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 428 bytes |
コンパイル時間 | 393 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 99,200 KB |
最終ジャッジ日時 | 2024-07-02 12:55:39 |
合計ジャッジ時間 | 5,104 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
from math import gcd import sys readline = sys.stdin.readline a,b,c,d = map(int,readline().split()) n = int(input()) xy = [list(map(int,readline().split())) for _ in range(n)] D = a*d - b*c if D: s = set(((d*x-c*y)%D, (a*y-b*x)%D) for x,y in xy) print(len(s)) exit() p,q = (gcd(a,c), b//(a//gcd(a,c))) if a else (a//(b//gcd(b,d)), gcd(b,d)) s = set((p*y-q*x,x%p) if p else (p*y-q*x,y%q) for x,y in xy) print(len(s))