結果

問題 No.849 yuki国の分割統治
ユーザー convexineqconvexineq
提出日時 2019-07-05 22:12:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 878 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 43,380 KB
最終ジャッジ日時 2024-04-16 07:32:29
合計ジャッジ時間 8,716 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
11,008 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 411 ms
31,868 KB
testcase_09 AC 407 ms
30,924 KB
testcase_10 AC 446 ms
29,184 KB
testcase_11 AC 381 ms
29,448 KB
testcase_12 AC 418 ms
28,032 KB
testcase_13 AC 443 ms
32,112 KB
testcase_14 AC 432 ms
29,440 KB
testcase_15 AC 390 ms
30,664 KB
testcase_16 AC 406 ms
37,580 KB
testcase_17 AC 422 ms
27,648 KB
testcase_18 AC 412 ms
38,224 KB
testcase_19 AC 427 ms
29,568 KB
testcase_20 AC 450 ms
35,028 KB
testcase_21 AC 395 ms
27,264 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 429 ms
43,380 KB
testcase_26 AC 31 ms
10,880 KB
testcase_27 AC 30 ms
10,880 KB
testcase_28 AC 31 ms
10,880 KB
testcase_29 AC 31 ms
10,880 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:
    g = gcd(a,c)
#    print(a,b,c,d,g)
    assert b%g==0
    p,q = a//g, b//g
    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