結果
問題 | No.673 カブトムシ |
ユーザー |
![]() |
提出日時 | 2020-02-04 22:03:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,045 bytes |
コンパイル時間 | 1,995 ms |
コンパイル使用メモリ | 192,720 KB |
最終ジャッジ日時 | 2025-01-08 22:07:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 2 |
ソースコード
#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) { 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; }