結果

問題 No.673 カブトムシ
ユーザー kurimupykurimupy
提出日時 2020-06-15 23:07:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 454 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 10,616 KB
実行使用メモリ 8,216 KB
最終ジャッジ日時 2023-09-16 10:36:09
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,200 KB
testcase_01 AC 15 ms
8,208 KB
testcase_02 AC 15 ms
8,112 KB
testcase_03 AC 15 ms
8,060 KB
testcase_04 AC 15 ms
8,084 KB
testcase_05 AC 16 ms
8,136 KB
testcase_06 AC 15 ms
8,188 KB
testcase_07 AC 15 ms
8,180 KB
testcase_08 AC 15 ms
8,148 KB
testcase_09 AC 15 ms
8,076 KB
testcase_10 AC 15 ms
8,136 KB
testcase_11 AC 15 ms
8,216 KB
testcase_12 AC 15 ms
8,120 KB
testcase_13 AC 15 ms
8,180 KB
testcase_14 AC 16 ms
8,196 KB
testcase_15 AC 16 ms
8,216 KB
testcase_16 AC 15 ms
8,084 KB
testcase_17 AC 16 ms
8,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

b, c, n = map(int, input().split())
mod = 10**9 + 7


def cal(X):
    #return c**X+    .... c
    if X == 1:
        return c % mod
    elif X == 0:
        return 1

    else:
        if X % 2 == 0:
            K = cal(X//2)
            return K*(pow(c, X//2, mod)+1) % mod
        elif X % 2 != 0:
            return (pow(c, X, mod)+cal(X-1)) % mod


if c == 1:
    print(b*n % mod)
    exit()
else:
    ans = b*cal(n)
    print(ans % mod)
    exit()

0