結果
| 問題 |
No.673 カブトムシ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-15 00:24:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,477 bytes |
| コンパイル時間 | 1,805 ms |
| コンパイル使用メモリ | 159,248 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-27 17:03:24 |
| 合計ジャッジ時間 | 2,927 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 6 WA * 8 |
ソースコード
#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; 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;
}