結果

問題 No.891 隣接3項間の漸化式
ユーザー buey_tbuey_t
提出日時 2023-03-12 19:19:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,931 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 88,216 KB
最終ジャッジ日時 2023-10-18 10:44:36
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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
    from copy import deepcopy
    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 matmul(a, b, mod):
        m = len(a)
        l = len(a[0])
        n = len(b[0])
        ret = [[0] * n for _ in range(m)]
        for i in range(m):
            for j in range(n):
                e = 0
                for k in range(l):
                    e = (e + a[i][k] * b[k][j]) % mod
                ret[i][j] = e
        return ret
    
    
    def matpow(X, exp, mod):
        Y = [[int(i == j) for j in range(len(X))] for i in range(len(X))]
        while exp > 0:
            if exp & 1:
                Y = matmul(X, Y, mod)
            X = matmul(X, X, mod)
            exp >>= 1
        return Y
    
    a,b,n = map(int, input().split())
    
    A = [[a,b],[1,0]]
    
    B = matpow(A,n-1,mod1)
    
    print(B[0][0]%mod1)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0