結果

問題 No.849 yuki国の分割統治
ユーザー convexineqconvexineq
提出日時 2021-09-20 09:13:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 100,048 KB
最終ジャッジ日時 2023-09-15 08:45:51
合計ジャッジ時間 5,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,232 KB
testcase_01 AC 73 ms
71,232 KB
testcase_02 AC 72 ms
70,888 KB
testcase_03 AC 71 ms
71,080 KB
testcase_04 AC 71 ms
71,064 KB
testcase_05 AC 71 ms
71,228 KB
testcase_06 AC 72 ms
71,176 KB
testcase_07 AC 175 ms
87,316 KB
testcase_08 AC 146 ms
89,620 KB
testcase_09 AC 148 ms
89,492 KB
testcase_10 AC 155 ms
87,660 KB
testcase_11 AC 143 ms
87,336 KB
testcase_12 AC 150 ms
87,476 KB
testcase_13 AC 156 ms
90,012 KB
testcase_14 AC 153 ms
89,112 KB
testcase_15 AC 145 ms
89,096 KB
testcase_16 AC 169 ms
97,128 KB
testcase_17 AC 154 ms
87,000 KB
testcase_18 AC 172 ms
97,336 KB
testcase_19 AC 159 ms
88,256 KB
testcase_20 AC 166 ms
93,396 KB
testcase_21 AC 151 ms
87,076 KB
testcase_22 AC 166 ms
95,240 KB
testcase_23 AC 161 ms
94,372 KB
testcase_24 AC 155 ms
87,544 KB
testcase_25 AC 169 ms
100,048 KB
testcase_26 AC 73 ms
71,176 KB
testcase_27 AC 71 ms
71,136 KB
testcase_28 AC 70 ms
71,136 KB
testcase_29 AC 71 ms
71,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0