結果

問題 No.1275 綺麗な式
ユーザー tanon_710tanon_710
提出日時 2020-10-30 23:09:33
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 912 ms
使用メモリ 75,956 KB
最終ジャッジ日時 2023-02-21 15:52:33
合計ジャッジ時間 8,022 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 76 ms
75,560 KB
testcase_01 AC 76 ms
75,760 KB
testcase_02 AC 77 ms
75,564 KB
testcase_03 AC 78 ms
75,448 KB
testcase_04 AC 77 ms
75,884 KB
testcase_05 AC 77 ms
75,668 KB
testcase_06 AC 77 ms
75,764 KB
testcase_07 AC 78 ms
75,788 KB
testcase_08 AC 77 ms
75,704 KB
testcase_09 AC 78 ms
75,764 KB
testcase_10 AC 77 ms
75,688 KB
testcase_11 AC 76 ms
75,836 KB
testcase_12 AC 77 ms
75,604 KB
testcase_13 AC 81 ms
75,772 KB
testcase_14 AC 77 ms
75,664 KB
testcase_15 AC 76 ms
75,660 KB
testcase_16 AC 78 ms
75,488 KB
testcase_17 AC 77 ms
75,848 KB
testcase_18 AC 76 ms
75,776 KB
testcase_19 AC 77 ms
75,756 KB
testcase_20 AC 76 ms
75,460 KB
testcase_21 AC 76 ms
75,552 KB
testcase_22 AC 77 ms
75,948 KB
testcase_23 AC 76 ms
75,800 KB
testcase_24 AC 77 ms
75,956 KB
testcase_25 AC 78 ms
75,468 KB
testcase_26 AC 77 ms
75,488 KB
testcase_27 AC 75 ms
75,796 KB
testcase_28 AC 76 ms
75,776 KB
testcase_29 AC 77 ms
75,720 KB
testcase_30 AC 74 ms
75,644 KB
testcase_31 AC 76 ms
75,704 KB
testcase_32 AC 76 ms
75,816 KB
testcase_33 AC 76 ms
75,764 KB
testcase_34 AC 77 ms
75,740 KB
testcase_35 AC 76 ms
75,764 KB
testcase_36 AC 77 ms
75,552 KB
testcase_37 AC 75 ms
75,556 KB
testcase_38 AC 77 ms
75,724 KB
testcase_39 AC 77 ms
75,612 KB
testcase_40 AC 76 ms
75,488 KB
testcase_41 AC 76 ms
75,752 KB
testcase_42 AC 76 ms
75,708 KB
testcase_43 AC 75 ms
75,828 KB
testcase_44 AC 78 ms
75,708 KB
testcase_45 AC 77 ms
75,864 KB
testcase_46 AC 79 ms
75,772 KB
testcase_47 AC 78 ms
75,728 KB
testcase_48 AC 77 ms
75,496 KB
testcase_49 AC 78 ms
75,548 KB
testcase_50 AC 77 ms
75,564 KB
testcase_51 AC 77 ms
75,716 KB
testcase_52 AC 77 ms
75,788 KB
testcase_53 AC 77 ms
75,832 KB
testcase_54 AC 77 ms
75,564 KB
testcase_55 AC 77 ms
75,772 KB
testcase_56 AC 76 ms
75,820 KB
testcase_57 AC 76 ms
75,804 KB
testcase_58 AC 76 ms
75,912 KB
testcase_59 AC 76 ms
75,552 KB
testcase_60 AC 77 ms
75,572 KB
testcase_61 AC 75 ms
75,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7

def prod(a,b):
    ret=[[0,0],[0,0]]
    for i in range(2):
        for j in range(2):
            for k in range(2):
                ret[i][j]+=a[i][k]*b[k][j]
            ret[i][j]%=mod
    return ret

a,b=map(int,input().split())
n=int(input())
a1=2*a
a2=2*(a**2+b)
if n==0:
    print(2)
elif n==1:
    print(a1)
elif n==2:
    print(a2)
else:
    n-=2
    mat=[[1,0],[0,1]]
    coef=[[2*a,-(a**2-b)],[1,0]]
    for i in range(60):
        if n&(2**i):
            mat=prod(mat,coef)
        coef=prod(coef,coef)
    print((mat[0][0]*a2+mat[0][1]*a1)%mod)
0