結果

問題 No.673 カブトムシ
ユーザー 👑 obakyanobakyan
提出日時 2019-05-02 09:59:28
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 896 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 71,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 16:14:01
合計ジャッジ時間 1,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#define L64 long long
#define MOD (1000000007LL)

L64 modpow(L64 src, L64 pow, L64 mod)
{
  L64 res = 1;
  while (0 < pow) {
    if (pow % 2 == 1) {
      res = (res * src) % mod;
      pow--;
    }
    src = (src * src) % mod;
    pow /= 2;
  }
  return res;
}

L64 modinv(L64 src, L64 mod)
{
  return modpow(src, mod - 2, mod);
}

int main(void)
{
  L64 b, c, d;
  std::cin >> b >> c >> d;
  if(c == 1LL) {
    L64 ans = ((d % MOD) * (b % MOD)) % MOD;
    std::cout << ans << std::endl;
  } else {
    L64 ans = modinv((c - 1LL) % MOD, MOD);
    ans = (ans * (c % MOD)) % MOD;
    ans = (ans * (b % MOD)) % MOD;
    L64 mul = modpow(c % MOD, d, MOD) - 1;
    ans = (ans * mul) % MOD;
    std::cout << ans << std::endl;
  }
}
0