結果

問題 No.849 yuki国の分割統治
ユーザー titiatitia
提出日時 2019-07-12 07:11:38
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
RE  
実行時間 -
コード長 773 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 47,500 KB
最終ジャッジ日時 2023-07-29 01:41:34
合計ジャッジ時間 6,731 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,044 KB
testcase_01 AC 17 ms
8,100 KB
testcase_02 AC 17 ms
8,312 KB
testcase_03 AC 16 ms
8,108 KB
testcase_04 AC 16 ms
8,108 KB
testcase_05 AC 16 ms
8,108 KB
testcase_06 AC 16 ms
8,468 KB
testcase_07 RE -
testcase_08 AC 209 ms
37,484 KB
testcase_09 AC 229 ms
39,688 KB
testcase_10 AC 241 ms
40,000 KB
testcase_11 AC 213 ms
35,512 KB
testcase_12 AC 225 ms
35,244 KB
testcase_13 AC 254 ms
41,240 KB
testcase_14 AC 229 ms
36,544 KB
testcase_15 AC 196 ms
36,036 KB
testcase_16 AC 247 ms
43,768 KB
testcase_17 AC 227 ms
41,252 KB
testcase_18 AC 239 ms
43,772 KB
testcase_19 AC 241 ms
41,988 KB
testcase_20 AC 242 ms
43,896 KB
testcase_21 AC 224 ms
34,864 KB
testcase_22 AC 242 ms
43,904 KB
testcase_23 AC 238 ms
43,756 KB
testcase_24 AC 235 ms
42,168 KB
testcase_25 AC 241 ms
47,500 KB
testcase_26 AC 16 ms
8,052 KB
testcase_27 AC 16 ms
8,196 KB
testcase_28 AC 16 ms
8,352 KB
testcase_29 AC 17 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

input = sys.stdin.readline

def lcm(a,b):
    return a*b//math.gcd(a,b)

a,b,c,d=map(int,input().split())
N=int(input())
P=[list(map(int,input().split())) for i in range(N)]


if a*d-b*c==0:
    a1=math.gcd(a,c)
    b1=b//(a//a1)

    def rep_point(p,q):
        k=p//a1

        return p-k*a1,q-k*b1

    Q=[rep_point(P[i][0],P[i][1]) for i in range(N)]

    print(len(set(Q)))
    sys.exit()

x = lcm(a,c)

if a==0:
    t=abs(b)
    a,b=c,d
    
    
else:

    while c!=0:
        if a>c:
            a,b,c,d=c,d,a,b
            
        r,q=divmod(c,a)
        c,d=q,d-b*r

    t = abs(d)   

def rep_point(p,q):
    k=p//a

    p-=k*a
    q-=k*b

    q=q%t

    return p,q

Q=[rep_point(P[i][0],P[i][1]) for i in range(N)]

print(len(set(Q)))

0