結果

問題 No.1073 無限すごろく
ユーザー Kiri8128Kiri8128
提出日時 2020-05-08 00:49:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 8,424 KB
最終ジャッジ日時 2023-09-16 08:15:56
合計ジャッジ時間 1,856 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,204 KB
testcase_01 AC 16 ms
8,060 KB
testcase_02 AC 17 ms
8,308 KB
testcase_03 AC 16 ms
8,220 KB
testcase_04 AC 17 ms
8,232 KB
testcase_05 AC 16 ms
8,164 KB
testcase_06 AC 16 ms
8,228 KB
testcase_07 AC 15 ms
8,208 KB
testcase_08 AC 15 ms
8,288 KB
testcase_09 AC 16 ms
8,324 KB
testcase_10 AC 16 ms
8,288 KB
testcase_11 AC 16 ms
8,308 KB
testcase_12 AC 16 ms
8,316 KB
testcase_13 AC 17 ms
8,288 KB
testcase_14 AC 17 ms
8,316 KB
testcase_15 AC 17 ms
8,196 KB
testcase_16 AC 17 ms
8,336 KB
testcase_17 AC 17 ms
8,372 KB
testcase_18 AC 17 ms
8,276 KB
testcase_19 AC 18 ms
8,288 KB
testcase_20 AC 18 ms
8,284 KB
testcase_21 AC 18 ms
8,244 KB
testcase_22 AC 17 ms
8,360 KB
testcase_23 AC 19 ms
8,324 KB
testcase_24 AC 19 ms
8,320 KB
testcase_25 AC 18 ms
8,236 KB
testcase_26 AC 19 ms
8,332 KB
testcase_27 AC 19 ms
8,352 KB
testcase_28 AC 21 ms
8,336 KB
testcase_29 AC 21 ms
8,276 KB
testcase_30 AC 20 ms
8,272 KB
testcase_31 AC 21 ms
8,392 KB
testcase_32 AC 20 ms
8,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mmult(A, B):
    global mod
    n, m, l = len(A), len(B), len(B[0])
    ret = [[0]*l for _ in range(n)]
    for i in range(n):
        for j in range(m):
            for k in range(l):
                ret[i][k] = (ret[i][k]+A[i][j]*B[j][k])%mod
    return ret
def mpow(A, n):
    if n == 0: return [[1 if i==j else 0 for j in range(len(A))] for i in range(len(A))]
    return mmult(mpow(A, n-1), A) if n % 2 else mpow(mmult(A, A), n//2)

mod = 10**9+7
t = (mod + 1) // 6
X = [[0,0,0,0,0,t],[1,0,0,0,0,t],[0,1,0,0,0,t],[0,0,1,0,0,t],[0,0,0,1,0,t],[0,0,0,0,1,t]]
N = int(input())
print(mpow(X, N)[-1][-1])
0