結果

問題 No.891 隣接3項間の漸化式
ユーザー buey_tbuey_t
提出日時 2023-03-12 18:56:22
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,844 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 93,620 KB
最終ジャッジ日時 2023-10-18 10:44:01
合計ジャッジ時間 6,254 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
88,548 KB
testcase_01 AC 133 ms
84,076 KB
testcase_02 AC 134 ms
84,072 KB
testcase_03 AC 136 ms
84,076 KB
testcase_04 AC 134 ms
84,076 KB
testcase_05 AC 136 ms
84,076 KB
testcase_06 AC 134 ms
84,072 KB
testcase_07 AC 135 ms
84,088 KB
testcase_08 AC 135 ms
84,076 KB
testcase_09 AC 132 ms
84,076 KB
testcase_10 AC 134 ms
84,076 KB
testcase_11 AC 133 ms
84,072 KB
testcase_12 AC 133 ms
84,072 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    try:
        import pypyjit
        pypyjit.set_param('max_unroll_recursion=-1')
    except:
        pass
    try:
        import sys
        sys.setrecursionlimit(10**7)
    except:
        pass
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    def dot(A1,A2,n):
        # n:行列のサイズ
        A = [[0]*n for _ in range(n)]
        for i in range(n):
            for j in range(n):
                for k in range(n):
                    A[i][j] += A1[i][k]*A2[k][j]%mod1
        return A
        
    def pow_mat(A,k,n):
        # A:累乗する行列, k:累乗数, n:行列Aのサイズ
        P = [[0]*n for _ in range(n)]
        for i in range(n):
            P[i][i] = 1
        while k:
            if k&1:
                P = dot(P,A,n)
            A = dot(A,A,n)
            k >>= 1
        return P
    
    a,b,n = map(int, input().split())
    
    A = [[a,b],[1,0]]
    
    ls = pow_mat(A,n-1,2)
    
    print(ls[0][0]%mod1)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0