結果

問題 No.1275 綺麗な式
ユーザー mkawa2mkawa2
提出日時 2021-09-02 00:46:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 867 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 11,088 KB
実行使用メモリ 154,312 KB
最終ジャッジ日時 2023-08-19 07:56:54
合計ジャッジ時間 60,845 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 20 ms
8,596 KB
testcase_31 AC 20 ms
8,668 KB
testcase_32 AC 100 ms
21,408 KB
testcase_33 AC 20 ms
8,792 KB
testcase_34 AC 40 ms
12,088 KB
testcase_35 AC 20 ms
8,808 KB
testcase_36 AC 24 ms
9,648 KB
testcase_37 AC 21 ms
8,816 KB
testcase_38 AC 215 ms
41,200 KB
testcase_39 AC 49 ms
13,476 KB
testcase_40 AC 20 ms
8,728 KB
testcase_41 RE -
testcase_42 AC 19 ms
8,656 KB
testcase_43 AC 20 ms
8,684 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**9
# md = 998244353
md = 10**9+7

from functools import lru_cache

@lru_cache(None)
def f(n):
    if n == 0: return 2
    if n == 1: return (2*a)%md
    if n%2: return (f(n-1)*2*a-(a**2-b)*f(n-2))%md
    return (f(n//2)**2%md-2*pow(a**2-b, n//2, md))%md

a, b = LI()
n = II()
print(f(n))
0