結果

問題 No.849 yuki国の分割統治
ユーザー convexineqconvexineq
提出日時 2019-07-05 22:19:13
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 375 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 11,016 KB
実行使用メモリ 40,672 KB
最終ジャッジ日時 2023-07-28 23:41:39
合計ジャッジ時間 8,429 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,392 KB
testcase_01 AC 16 ms
8,408 KB
testcase_02 AC 17 ms
8,392 KB
testcase_03 AC 16 ms
8,396 KB
testcase_04 AC 16 ms
8,288 KB
testcase_05 AC 16 ms
8,264 KB
testcase_06 AC 16 ms
8,248 KB
testcase_07 AC 247 ms
26,196 KB
testcase_08 AC 338 ms
29,192 KB
testcase_09 AC 348 ms
28,564 KB
testcase_10 AC 367 ms
26,628 KB
testcase_11 AC 320 ms
27,004 KB
testcase_12 AC 344 ms
25,436 KB
testcase_13 AC 371 ms
29,604 KB
testcase_14 AC 353 ms
26,880 KB
testcase_15 AC 314 ms
28,036 KB
testcase_16 AC 346 ms
35,044 KB
testcase_17 AC 344 ms
25,052 KB
testcase_18 AC 347 ms
35,608 KB
testcase_19 AC 357 ms
27,100 KB
testcase_20 AC 375 ms
32,280 KB
testcase_21 AC 330 ms
24,996 KB
testcase_22 AC 281 ms
34,020 KB
testcase_23 AC 278 ms
32,848 KB
testcase_24 AC 259 ms
26,540 KB
testcase_25 AC 364 ms
40,672 KB
testcase_26 AC 16 ms
8,428 KB
testcase_27 AC 17 ms
8,276 KB
testcase_28 AC 16 ms
8,472 KB
testcase_29 AC 16 ms
8,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

from math import gcd

a,b,c,d = [int(i) for i in readline().split()]
n = int(input())
xy = [[int(i) for i in readline().split()] for _ in range(n)]


def heikouidou(x,y,pp,qq,g,h): #(e,f)に沿って(g,h)以上のぎりぎり
    m = (x*h-y*g)//(h*pp-g*qq)
    x -= m*pp
    y-= m*qq
    return (x,y)
    
    
    
if a*d == b*c:
    if a==0 and c==0:
        g = gcd(b,d)
        p,q = a//(b//g), g
    else:
        g = gcd(a,c)
        p,q = g, b//(a//g)

#    print(a,b,c,d,g)
#    assert b%g==0
    s = set()
    for x,y in xy:
        s.add(heikouidou(x,y,p,q,-q,p))
    print(len(s))
#    print(s)
    exit()

        
s = set()
for x,y in xy:
#    print(x,y)
    x,y = heikouidou(x,y,a,b,c,d)
#    print(x,y)
    x,y = heikouidou(x,y,c,d,a,b)
#    print(x,y)
    s.add((x,y))
print(len(s))
#print(s)
exit()




         
0