結果

問題 No.673 カブトムシ
ユーザー face4face4
提出日時 2018-08-27 19:58:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 672 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 63,972 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 19:33:56
合計ジャッジ時間 1,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// mod本当にめんどくさい
#include<iostream>
using namespace std;

typedef long long ll;
const ll mod = 1000000007;

// a^b mod p を計算する
ll modpow(ll a, ll b, ll p){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    ll b, c, d;
    cin >> b >> c >> d;

    b %= mod;

    if(c == 1){
        cout << (b*(d%mod))%mod << endl;
        return 0;
    }

    ll ans = ( (modpow(c,d,mod)%mod *( ((c-1)%mod*b+b)%mod)%mod +mod-b )%mod * modpow(c-1,mod-2,mod)%mod + mod - b)%mod;
    
    cout << ans << endl;
    return 0;
}
0