結果

問題 No.673 カブトムシ
コンテスト
ユーザー 0w1
提出日時 2018-04-14 00:11:47
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 696 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,903 ms
コンパイル使用メモリ 210,568 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-06 23:06:27
合計ジャッジ時間 3,155 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0