結果

問題 No.665 Bernoulli Bernoulli
ユーザー koba-e964koba-e964
提出日時 2017-09-27 21:39:08
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 603 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 55,808 KB
実行使用メモリ 13,752 KB
最終ジャッジ日時 2024-04-27 14:54:58
合計ジャッジ時間 3,910 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;

ll powmod(ll a, ll e) {
  ll sum = 1;
  ll cur = a;
  while (e > 0) {
    if (e % 2) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}

int main(void) {
  ll n;
  int k;
  cin >> n >> k;
  assert (1 <= n);
  assert (n <= (ll)1e16);
  assert (1 <= k);
  assert (k <= 10000);
  n %= mod;

  ll sum = 0;
  REP(i, 1, n + 1) {
    sum = (sum + powmod(i, k)) % mod;
  }
  cout << sum  << endl;
}
0