結果

問題 No.435 占い(Extra)
ユーザー titiatitia
提出日時 2023-04-26 02:32:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2024-04-27 10:05:20
合計ジャッジ時間 16,612 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
17,820 KB
testcase_01 WA -
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 WA -
testcase_07 AC 32 ms
10,752 KB
testcase_08 AC 47 ms
10,880 KB
testcase_09 AC 44 ms
10,752 KB
testcase_10 AC 172 ms
10,752 KB
testcase_11 AC 169 ms
10,752 KB
testcase_12 AC 1,416 ms
10,880 KB
testcase_13 AC 1,395 ms
10,752 KB
testcase_14 AC 1,390 ms
10,880 KB
testcase_15 AC 1,354 ms
10,752 KB
testcase_16 AC 1,334 ms
10,752 KB
testcase_17 AC 1,907 ms
10,752 KB
testcase_18 AC 1,456 ms
10,880 KB
testcase_19 AC 1,436 ms
10,752 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 3を除けば9の余りを考えて良い。

INV=[0,1,5,0,7,2,0,4,8]

T=int(input())
for tests in range(T):
    n,x,a,b,m=map(int,input().split())

    now=x

    flag0=0
    if now==0:
        flag0=1

    ANS=0

    TWO=1
    THREE=0

    for i in range(n):
        if i==0:
            ANS=(ANS+now%10)%9
            continue

        now=((now^a)+b)%m

        if i==n-1:
            ANS=(ANS+now%10)%9
            continue

        if now%10!=0:
            flag0=0

        x=i
        while x%3==0:
            x//=3
            THREE-=1

        TWO=TWO*INV[x%9]%9

        x=n-i

        while x%3==0:
            x//=3
            THREE+=1

        TWO=TWO*x%9

        #print(TWO,THREE)

        if THREE==0:
            ANS=(ANS+(now%10)*TWO)%9
        elif THREE==1:
            ANS=(ANS+(now%10)*TWO*3)%9

    if ANS==0:
        ANS=9

    print(ANS)
0