結果
| 問題 |
No.673 カブトムシ
|
| コンテスト | |
| ユーザー |
Konton7
|
| 提出日時 | 2020-02-04 22:04:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,063 bytes |
| コンパイル時間 | 2,319 ms |
| コンパイル使用メモリ | 191,960 KB |
| 最終ジャッジ日時 | 2025-01-08 22:07:45 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
ll pow_mod(ll p, ll q, int mod)
{
ll ret, r;
ret = 1;
r = p;
while (q > 0)
{
if (q % 2)
{
ret *= r;
ret %= mod;
}
r = (r * r) % mod;
q /= 2;
}
return ret % mod;
}
int main()
{
#ifdef DEBUG
cout << "DEBUG MODE" << endl;
ifstream in("input.txt"); //for debug
cin.rdbuf(in.rdbuf()); //for debug
#endif
const int mod = 1e9 + 7;
ll b, c, d, ans;
cin >> b >> c >> d;
b %= mod, c %= mod;
if (c == 1)
{
d %= mod;
ans = (b * d) % mod;
}
else
{
ans = (b * c) % mod;
ans *= pow_mod(c, d, mod) - 1;
ans %= mod;
ans *= pow_mod(c-1, mod-2, mod);
ans %= mod;
}
cout << ans << endl;
return 0;
}
Konton7