結果

問題 No.673 カブトムシ
ユーザー kohei2019kohei2019
提出日時 2022-03-10 00:04:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 71,572 KB
最終ジャッジ日時 2023-10-12 01:40:47
合計ジャッジ時間 2,964 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,140 KB
testcase_01 AC 76 ms
71,292 KB
testcase_02 WA -
testcase_03 AC 76 ms
70,992 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 75 ms
71,412 KB
testcase_07 AC 75 ms
71,192 KB
testcase_08 WA -
testcase_09 AC 77 ms
71,176 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def modPow(a,n,mod):#繰り返し二乗法 a**n % mod
    if n==0:
        return 1
    if n==1:
        return a%mod
    if n & 1:
        return (a*modPow(a,n-1,mod)) % mod
    t = modPow(a,n>>1,mod)
    return (t*t)%mod

def invmod(a,mod):#mod逆元
    if a == 0:
        return 0
    if a == 1:
        return 1
    return (-invmod(mod % a, mod) * (mod // a)) % mod

B,C,D = map(int,input().split())
mod = 10**9+7
if C == 1:
    print(B*D%mod)
    exit()

ans = ((B%mod)*(C%mod)*(modPow(C%mod, D, mod)-1)*invmod((C-1)%mod, mod))%mod
if C-1 % mod:
    print((B*C*D)%mod)
    exit()
print(ans)
0