結果

問題 No.673 カブトムシ
ユーザー GrayCoder
提出日時 2025-08-11 19:52:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 2,160 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-08-11 19:52:48
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

MOD = 1000000007


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, MOD - 2, MOD))
        else:
            return ModInt(self.x * pow(other, MOD - 2, MOD))

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, MOD))
        else:
            return ModInt(pow(self.x, other, MOD))

    __radd__ = __add__

    def __rsub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x * pow(self.x, MOD - 2, MOD))
        else:
            return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, MOD))
        else:
            return ModInt(pow(other, self.x, MOD))


def main():
    # sys.setrecursionlimit(100000)
    input = lambda: sys.stdin.readline()[:-1]
    B, C, D = map(int, input().split())

    if not (C - 1) % MOD:
        ans = ModInt(B) * ModInt(D)
    else:
        B, C = map(ModInt, (B, C))
        ans = B * ((C**D) - 1) / (C - 1) * C
    print(ans)


if not __debug__:
    f = open(sys.argv[1], "r")
    sys.stdin = f

# try:
#     sys.set_int_max_str_digits(100000)
# except AttributeError:
#     pass

main()
0