結果
問題 | No.673 カブトムシ |
ユーザー |
![]() |
提出日時 | 2018-09-06 18:57:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 1,650 ms |
コンパイル使用メモリ | 167,056 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 04:18:09 |
合計ジャッジ時間 | 2,226 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; using uint64 = unsigned long long; const int64 MOD = 1e9 + 7; int64 table[50]; // table[n]:=\sum_{i=1}^{2^n} c^{i} int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int64 B, C, D; cin >> B >> C >> D; B %= MOD; C %= MOD; int64 ans = 0, cum = 1, powC = C; int pos = 0; table[pos] = C; while (D > 0) { if (D & 1) { (ans += cum * table[pos]) %= MOD; (cum *= powC) %= MOD; } table[pos + 1] = (table[pos] + powC * table[pos]) % MOD; (powC *= powC) %= MOD; pos++; D >>= 1; } (ans *= B) %= MOD; cout << ans << endl; return 0; }