結果

問題 No.2156 ぞい文字列
ユーザー hibit_athibit_at
提出日時 2022-11-13 16:25:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-10-13 00:52:52
合計ジャッジ時間 1,414 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,852 KB
testcase_01 AC 16 ms
7,924 KB
testcase_02 AC 16 ms
7,880 KB
testcase_03 AC 17 ms
7,876 KB
testcase_04 AC 16 ms
7,808 KB
testcase_05 AC 17 ms
7,816 KB
testcase_06 AC 17 ms
7,788 KB
testcase_07 AC 17 ms
7,868 KB
testcase_08 AC 16 ms
7,748 KB
testcase_09 AC 16 ms
7,796 KB
testcase_10 AC 16 ms
7,932 KB
testcase_11 AC 17 ms
7,892 KB
testcase_12 AC 16 ms
7,880 KB
testcase_13 AC 16 ms
7,852 KB
testcase_14 AC 16 ms
7,796 KB
testcase_15 AC 16 ms
7,816 KB
testcase_16 AC 16 ms
7,796 KB
testcase_17 AC 16 ms
7,812 KB
testcase_18 AC 16 ms
7,820 KB
testcase_19 AC 17 ms
7,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=2
P=998244353
def product(a,b):
    c=[[0 for i in range(n)] for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                c[i][j]=(c[i][j]+a[i][k]*b[k][j])%P
    return c
def fibonacci(N):
    S=str(bin(N))[2:][::-1]
    M=len(S)
    L=[[[1,1],[1,0]]]
    for i in range(M-1):
        L.append(product(L[i],L[i]))
    R=[[1,0],[0,1]]
    for i in range(M):
        if S[i]=="1":
            R=product(R,L[i])
    return (R[0][1])
x=int(input())
print((fibonacci(x+1)-1)%998244353)
0