結果

問題 No.1275 綺麗な式
ユーザー _matumo_
提出日時 2020-11-24 14:12:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 238 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-23 18:37:44
合計ジャッジ時間 3,878 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

m=10**9+7
A,B=map(int,input().split())
N=int(input())

def f(a,b,c,n):
    x,y=1,0
    while n:
        if n&1: x,y=(x*a+y*c*b)%m,(x*c+y*a)%m
        a,c=(a*a+c*c*b)%m,a*c*2%m
        n=n>>1
    return x

print((f(A,B,1,N)+f(A,B,-1,N))%m)
0