結果
| 問題 | No.673 カブトムシ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-01-15 00:25:44 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 2,491 bytes | 
| コンパイル時間 | 1,481 ms | 
| コンパイル使用メモリ | 160,084 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-02 21:30:58 | 
| 合計ジャッジ時間 | 2,136 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<int64_t MOD>
class ModInt {
    int64_t value;
public:
    // constructor
    inline ModInt(int64_t val = 0) noexcept :
        value((val >= MOD) ? (val % MOD) : (val < 0) ? ((val + MOD) % MOD) : val) {}
    // プリミティブ整数型へのキャスト (型の明示:必要)
    template<class Int>
    explicit inline operator Int() const noexcept { return static_cast<Int>(value); }
    inline ModInt inv() const noexcept {
        return ModInt<MOD>::pow(value, MOD-2);
    }
    inline ModInt& operator+=(ModInt x) noexcept {
        if ((value += x.value) >= MOD) value -= MOD;
        return *this;
    }
    inline ModInt& operator-=(ModInt x) noexcept {
        if ((value -= x.value) < 0) value += MOD;
        return *this;
    }
    inline ModInt& operator*=(ModInt x) noexcept {
        value = (value * x.value) % MOD; return *this;
    }
    inline ModInt& operator/=(ModInt x) noexcept {
        value = (value * x.inv().value) % MOD; return *this;
    }
    inline ModInt& operator^=(int64_t x) noexcept {
        value = (int64_t)pow((int64_t)value, x);
        value %= MOD;
        return *this;
    }
    inline ModInt operator+(ModInt x) const noexcept { return ModInt(*this) += x; }
    inline ModInt operator-(ModInt x) const noexcept { return ModInt(*this) -= x; }
    inline ModInt operator*(ModInt x) const noexcept { return ModInt(*this) *= x; }
    inline ModInt operator/(ModInt x) const noexcept { return ModInt(*this) /= x; }
    inline ModInt operator^(int64_t x) const noexcept { return ModInt(*this) ^= x; }
    inline bool operator==(ModInt x) const noexcept { return value == x.value; }
    inline bool operator!=(ModInt x) const noexcept { return !(this->operator==(x)); }
    friend ostream& operator<<(ostream &os, ModInt x) noexcept { os << x.value; return os; }
    friend istream& operator>>(istream &is, ModInt &x) noexcept { is >> x.value, x.value%=MOD; return is; }
    static constexpr inline ModInt pow(int64_t n, int64_t p) noexcept {
        int64_t ret = 1;
        for(; p > 0; p >>= 1) {
            if (p & 1) ret = (ret * n) % MOD;
            n = (n * n) % MOD;
        }
        return ret;
    }
};
using modint = ModInt<int(1e9)+7>;
int main(){
    modint b, c;
    long long n;
    cin >> b >> c >> n;
    modint ans;
    if(c != 1){
        ans = (b * c * ((c^n) - 1)) / (c-1);
    }else{
        ans = b * n;
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        