結果

問題 No.849 yuki国の分割統治
コンテスト
ユーザー chocorusk
提出日時 2019-03-30 06:33:49
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 262 ms / 2,000 ms
+ 620µs
コード長 768 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 15,360 KB
実行使用メモリ 27,072 KB
最終ジャッジ日時 2026-09-11 06:47:30
合計ジャッジ時間 8,569 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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