結果
| 問題 | No.1073 無限すごろく | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-06 00:00:41 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                RE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 482 bytes | 
| コンパイル時間 | 298 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 44,336 KB | 
| 最終ジャッジ日時 | 2024-12-17 19:27:35 | 
| 合計ジャッジ時間 | 19,109 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 3 | 
| other | RE * 30 | 
ソースコード
import numpy as np
N = int(input())
MOD = 10 ** 9 + 7
modinv = lambda a, mod=MOD: pow(a, mod - 2, mod)
def pow_matrix_mod(x, n, mod=MOD):
    if not n:
        return np.eye(6, dtype=np.object)
    if n % 2 == 0:
        return pow_matrix_mod(x @ x % mod, n // 2) % mod
    else:
        return x @ pow_matrix_mod(x @ x % mod, (n - 1) // 2) % mod
A = np.zeros((6, 6), dtype=np.object)
A[0] = modinv(6)
for i in range(5):
    A[i + 1, i] = 1
print(pow_matrix_mod(A, N)[0, 0])
            
            
            
        