結果

問題 No.849 yuki国の分割統治
ユーザー chocoruskchocorusk
提出日時 2019-03-30 06:33:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 510 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 26,808 KB
最終ジャッジ日時 2024-04-16 07:00:56
合計ジャッジ時間 10,627 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,880 KB
testcase_01 AC 33 ms
10,880 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 38 ms
10,880 KB
testcase_04 AC 34 ms
11,008 KB
testcase_05 AC 33 ms
11,008 KB
testcase_06 AC 33 ms
10,880 KB
testcase_07 AC 432 ms
12,032 KB
testcase_08 AC 425 ms
17,004 KB
testcase_09 AC 443 ms
15,844 KB
testcase_10 AC 464 ms
12,416 KB
testcase_11 AC 402 ms
15,360 KB
testcase_12 AC 438 ms
11,776 KB
testcase_13 AC 476 ms
16,064 KB
testcase_14 AC 426 ms
12,928 KB
testcase_15 AC 402 ms
16,736 KB
testcase_16 AC 498 ms
21,044 KB
testcase_17 AC 436 ms
11,008 KB
testcase_18 AC 510 ms
21,556 KB
testcase_19 AC 497 ms
13,184 KB
testcase_20 AC 497 ms
18,488 KB
testcase_21 AC 414 ms
10,880 KB
testcase_22 AC 469 ms
20,148 KB
testcase_23 AC 472 ms
18,996 KB
testcase_24 AC 436 ms
12,668 KB
testcase_25 AC 509 ms
26,808 KB
testcase_26 AC 33 ms
11,008 KB
testcase_27 AC 32 ms
10,880 KB
testcase_28 AC 32 ms
10,880 KB
testcase_29 AC 33 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

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