結果

問題 No.849 yuki国の分割統治
ユーザー convexineqconvexineq
提出日時 2019-07-05 22:19:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 450 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,360 KB
最終ジャッジ日時 2024-04-16 07:37:42
合計ジャッジ時間 9,245 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 31 ms
11,008 KB
testcase_05 AC 33 ms
11,008 KB
testcase_06 AC 33 ms
10,752 KB
testcase_07 AC 305 ms
28,544 KB
testcase_08 AC 400 ms
31,632 KB
testcase_09 AC 416 ms
30,936 KB
testcase_10 AC 444 ms
29,184 KB
testcase_11 AC 389 ms
29,468 KB
testcase_12 AC 421 ms
27,904 KB
testcase_13 AC 444 ms
32,128 KB
testcase_14 AC 428 ms
29,440 KB
testcase_15 AC 382 ms
30,556 KB
testcase_16 AC 404 ms
37,472 KB
testcase_17 AC 421 ms
27,392 KB
testcase_18 AC 412 ms
38,108 KB
testcase_19 AC 428 ms
29,696 KB
testcase_20 AC 450 ms
34,908 KB
testcase_21 AC 384 ms
27,392 KB
testcase_22 AC 334 ms
36,448 KB
testcase_23 AC 337 ms
35,552 KB
testcase_24 AC 316 ms
29,056 KB
testcase_25 AC 423 ms
43,360 KB
testcase_26 AC 31 ms
11,008 KB
testcase_27 AC 30 ms
10,880 KB
testcase_28 AC 31 ms
10,752 KB
testcase_29 AC 32 ms
10,752 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