結果

問題 No.1073 無限すごろく
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-06-05 22:05:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,016 KB
実行使用メモリ 60,800 KB
最終ジャッジ日時 2024-05-09 21:21:08
合計ジャッジ時間 2,759 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,736 KB
testcase_01 AC 42 ms
52,608 KB
testcase_02 AC 45 ms
59,520 KB
testcase_03 AC 48 ms
52,480 KB
testcase_04 AC 42 ms
52,736 KB
testcase_05 AC 45 ms
57,984 KB
testcase_06 AC 44 ms
58,112 KB
testcase_07 AC 44 ms
58,240 KB
testcase_08 AC 42 ms
57,984 KB
testcase_09 AC 42 ms
58,112 KB
testcase_10 AC 42 ms
57,472 KB
testcase_11 AC 43 ms
57,984 KB
testcase_12 AC 45 ms
57,856 KB
testcase_13 AC 45 ms
59,392 KB
testcase_14 AC 44 ms
59,776 KB
testcase_15 AC 45 ms
59,264 KB
testcase_16 AC 45 ms
59,492 KB
testcase_17 AC 46 ms
59,904 KB
testcase_18 AC 45 ms
59,520 KB
testcase_19 AC 45 ms
59,392 KB
testcase_20 AC 46 ms
59,392 KB
testcase_21 AC 46 ms
59,264 KB
testcase_22 AC 46 ms
59,392 KB
testcase_23 AC 46 ms
60,160 KB
testcase_24 AC 50 ms
60,672 KB
testcase_25 AC 48 ms
60,416 KB
testcase_26 AC 48 ms
60,800 KB
testcase_27 AC 48 ms
60,160 KB
testcase_28 AC 48 ms
60,544 KB
testcase_29 AC 48 ms
60,800 KB
testcase_30 AC 48 ms
60,672 KB
testcase_31 AC 48 ms
60,800 KB
testcase_32 AC 49 ms
60,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

移動方がいくつあるか考えねぇと
→がNこあって、そこに|を入れる方法の数?
2^(N-1)通りの入れ方がある


"""

mod = 10**9+7
#行列A,Bの積(不可能だとエラー)
def matrix_mul(A,B):
 
    ans = [ [0] * len(B[0]) for i in range(len(A)) ]
 
    for ai in range(len(A)):
 
        for bj in range(len(B[0])):
 
            now = 0
            for same in range(len(A[0])):
                now += A[ai][same] * B[same][bj]
            ans[ai][bj] = now % mod
 
    return ans
 
#行列Aのx乗(当然正方行列じゃないとだめ)
def matrix_pow(A,x):
 
    B = [[A[i][j] for j in range(len(A[0]))] for i in range(len(A))]
    ans = [[0] * len(A[0]) for i in range(len(A))]
    for i in range(len(A)):
        ans[i][i] = 1
 
    while x > 0:
        if x % 2 == 1:
            ans = matrix_mul(ans,B)
        B = matrix_mul(B,B)
 
        x//=2
    return ans

N = int(input())

q = [ [0,0,0,0,0,1] ]
h = 166666668
mod = 10**9+7

a = [
     [0,0,0,0,0,h],
     [1,0,0,0,0,h],
     [0,1,0,0,0,h],
     [0,0,1,0,0,h],
     [0,0,0,1,0,h],
     [0,0,0,0,1,h],
    ]

ans = matrix_mul(q, matrix_pow(a,N) )
print (ans[0][-1])
0