結果

問題 No.891 隣接3項間の漸化式
ユーザー Konton7Konton7
提出日時 2019-09-28 13:18:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 53,932 KB
最終ジャッジ日時 2024-04-09 23:47:15
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,252 KB
testcase_01 AC 36 ms
52,688 KB
testcase_02 AC 35 ms
53,856 KB
testcase_03 AC 35 ms
53,696 KB
testcase_04 AC 34 ms
53,416 KB
testcase_05 AC 35 ms
52,260 KB
testcase_06 AC 35 ms
52,900 KB
testcase_07 AC 35 ms
52,476 KB
testcase_08 AC 35 ms
53,236 KB
testcase_09 AC 35 ms
52,760 KB
testcase_10 AC 34 ms
52,196 KB
testcase_11 AC 34 ms
53,416 KB
testcase_12 AC 34 ms
52,692 KB
testcase_13 AC 34 ms
52,928 KB
testcase_14 AC 33 ms
53,544 KB
testcase_15 AC 33 ms
53,020 KB
testcase_16 AC 33 ms
53,564 KB
testcase_17 AC 34 ms
52,408 KB
testcase_18 AC 33 ms
52,552 KB
testcase_19 AC 35 ms
53,092 KB
testcase_20 AC 33 ms
51,940 KB
testcase_21 AC 34 ms
53,080 KB
testcase_22 AC 34 ms
53,404 KB
testcase_23 AC 34 ms
52,884 KB
testcase_24 AC 34 ms
52,064 KB
testcase_25 AC 35 ms
52,960 KB
testcase_26 AC 34 ms
53,892 KB
testcase_27 AC 35 ms
53,932 KB
testcase_28 AC 35 ms
53,040 KB
testcase_29 AC 34 ms
53,248 KB
testcase_30 AC 35 ms
52,512 KB
testcase_31 AC 34 ms
53,080 KB
testcase_32 AC 35 ms
52,876 KB
testcase_33 AC 35 ms
53,556 KB
testcase_34 AC 34 ms
52,884 KB
testcase_35 AC 35 ms
53,824 KB
testcase_36 AC 34 ms
52,880 KB
testcase_37 AC 36 ms
52,872 KB
testcase_38 AC 36 ms
53,288 KB
testcase_39 AC 35 ms
52,528 KB
testcase_40 AC 34 ms
52,612 KB
testcase_41 AC 34 ms
53,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, n = [ int(v) for v in input().split() ]

path_mat = [ [a, b], [1, 0] ]
mod = 10**9+7

def mat_mul(inmat1,inmat2,m):
    outmat = [ [ 0 for j in range(m) ] for i in range(m) ]

    for i in range(m):
        for j in range(m):
            for g in range(m):
                outmat[i][j] += inmat1[i][g] * inmat2[g][j]
            outmat[i][j] %= mod
    return outmat


ans_mat = [ [ 1 if i == j else 0 for j in range(2) ] for i in range(2) ]

while n != 0:
    if n % 2 == 1:
        ans_mat = mat_mul(ans_mat,path_mat,2)
    n = n // 2
    path_mat = mat_mul(path_mat,path_mat,2)
    
print(ans_mat[1][0])
0