結果

問題 No.891 隣接3項間の漸化式
ユーザー taiga000629taiga000629
提出日時 2020-10-09 02:29:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 71,488 KB
最終ジャッジ日時 2023-09-27 12:10:25
合計ジャッジ時間 5,191 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,324 KB
testcase_01 AC 58 ms
71,152 KB
testcase_02 AC 60 ms
71,332 KB
testcase_03 AC 59 ms
71,192 KB
testcase_04 AC 58 ms
71,376 KB
testcase_05 AC 63 ms
71,100 KB
testcase_06 AC 61 ms
71,140 KB
testcase_07 AC 61 ms
71,284 KB
testcase_08 AC 60 ms
71,364 KB
testcase_09 AC 61 ms
71,144 KB
testcase_10 AC 58 ms
71,428 KB
testcase_11 AC 59 ms
71,244 KB
testcase_12 AC 62 ms
71,312 KB
testcase_13 AC 57 ms
71,096 KB
testcase_14 AC 59 ms
71,320 KB
testcase_15 AC 58 ms
71,356 KB
testcase_16 AC 60 ms
71,468 KB
testcase_17 AC 58 ms
71,276 KB
testcase_18 AC 60 ms
71,132 KB
testcase_19 AC 59 ms
71,280 KB
testcase_20 AC 62 ms
71,300 KB
testcase_21 AC 62 ms
71,324 KB
testcase_22 AC 59 ms
71,152 KB
testcase_23 AC 59 ms
71,096 KB
testcase_24 AC 60 ms
71,192 KB
testcase_25 AC 60 ms
71,088 KB
testcase_26 AC 62 ms
70,928 KB
testcase_27 AC 62 ms
71,096 KB
testcase_28 AC 58 ms
71,420 KB
testcase_29 AC 60 ms
71,380 KB
testcase_30 AC 58 ms
71,416 KB
testcase_31 AC 58 ms
71,192 KB
testcase_32 AC 60 ms
71,280 KB
testcase_33 AC 63 ms
71,416 KB
testcase_34 AC 60 ms
71,356 KB
testcase_35 AC 61 ms
71,488 KB
testcase_36 AC 60 ms
70,948 KB
testcase_37 AC 60 ms
71,360 KB
testcase_38 AC 62 ms
71,408 KB
testcase_39 AC 60 ms
71,264 KB
testcase_40 AC 58 ms
71,244 KB
testcase_41 AC 57 ms
71,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,n=map(int,input().split())
p=10**9+7

def f(n):
    if n==0:
        return [[1,0],[0,1]]
    elif n%2==1:
        z=f(n-1)
        y=[[a,b],[1,0]]
        return [[(y[0][0]*z[0][0]+y[0][1]*z[1][0])%p,(y[0][0]*z[0][1]+y[0][1]*z[1][1])%p],[(y[1][0]*z[0][0]+y[1][1]*z[1][0])%p,(y[1][0]*z[0][1]+y[1][1]*z[1][1])%p]]
    else:
        y=z=f(n//2)
        return [[(y[0][0] * z[0][0] + y[0][1] * z[1][0]) % p, (y[0][0] * z[0][1] + y[0][1] * z[1][1]) % p],[(y[1][0] * z[0][0] + y[1][1] * z[1][0]) % p, (y[1][0] * z[0][1] + y[1][1] * z[1][1]) % p]]

print(f(n)[1][0])


0