結果
問題 | No.673 カブトムシ |
ユーザー |
|
提出日時 | 2018-04-14 00:11:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 696 bytes |
コンパイル時間 | 2,185 ms |
コンパイル使用メモリ | 194,240 KB |
最終ジャッジ日時 | 2025-01-05 10:09:57 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; int int_pow(int v, int64_t p) { int r = 1; for (int64_t i = p; i; i >>= 1) { if (i & 1) r = 1LL * r * v % M; v = 1LL * v * v % M; } return r; } int sum_prod(int v, int64_t p) { int u = int_pow(v, p) - 1; int res = 1LL * u * int_pow(v - 1, M - 2) % M; (res -= 1) %= M; if (res < 0) res += M; return res; } signed main() { ios::sync_with_stdio(false); int64_t B, C, D; cin >> B >> C >> D; if (C == 1) { int64_t ans = B % M * (D % M) % M; cout << ans << endl; } else { B %= M; C %= M; int64_t ans = B * sum_prod(C, D + 1) % M; cout << ans << endl; } return 0; }