結果

問題 No.849 yuki国の分割統治
ユーザー chocorusk
提出日時 2019-03-30 06:33:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 493 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 26,676 KB
最終ジャッジ日時 2024-10-06 21:00:04
合計ジャッジ時間 10,305 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

a=list(map(int, input().split()))
def extgcd(a):
    if a[2]==0:
        return
    q=a[0]//a[2]
    a[0]-=a[2]*q
    a[1]-=a[3]*q
    a[0], a[2]=a[2], a[0]
    a[1], a[3]=a[3], a[1]
    extgcd(a)
sw=0
if a[0]==0 and a[2]==0:
    sw=1
    a[0], a[1]=a[1], a[0]
    a[2], a[3]=a[3], a[2]
extgcd(a)
n=int(input())
if a[3]==0:
    s=set()
    for i in range(n):
        x, y=map(int, input().split())
        if sw==1:
            x, y=y, x
        q=x//a[0]
        x-=a[0]*q
        y-=a[1]*q
        s.add((x, y))
    print(len(s))
else:
    if a[3]<0:
        a[3]=-a[3]
    s=set()
    for i in range(n):
        x, y=map(int, input().split())
        q=x//a[0]
        x-=a[0]*q
        y-=a[1]*q
        y=(y%a[3]+a[3])%a[3]
        s.add((x, y))
    print(len(s))
0