結果

問題 No.673 カブトムシ
ユーザー face4
提出日時 2018-08-27 18:54:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 63,616 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 20:06:18
合計ジャッジ時間 1,122 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 7 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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 * 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