結果

問題 No.1102 Remnants
ユーザー itohdakitohdak
提出日時 2020-07-03 23:52:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,091 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 204,296 KB
実行使用メモリ 6,348 KB
最終ジャッジ日時 2023-10-17 06:30:58
合計ジャッジ時間 3,933 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 50 ms
5,820 KB
testcase_06 AC 10 ms
4,348 KB
testcase_07 AC 67 ms
6,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 29 ms
4,764 KB
testcase_15 AC 22 ms
4,348 KB
testcase_16 AC 57 ms
6,084 KB
testcase_17 AC 54 ms
5,820 KB
testcase_18 AC 58 ms
5,820 KB
testcase_19 AC 21 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 34 ms
4,764 KB
testcase_22 AC 50 ms
5,556 KB
testcase_23 AC 39 ms
5,028 KB
testcase_24 AC 28 ms
4,500 KB
testcase_25 AC 59 ms
6,084 KB
testcase_26 AC 5 ms
4,348 KB
testcase_27 AC 16 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
ll modinv(ll a, ll m=mod) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; ll k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  ll ans = 0;
  vector<ll> comb(n);
  comb[0] = 1;
  for(int i=1; i<n; i++) {
    comb[i] = comb[i-1] * (k+i) %  mod * modinv(i) % mod;
  }
  rep(i, n) {
    (ans += A[i] * comb[i] % mod * comb[n-1-i] % mod) %= mod;
  }
  cout << ans << "\n";
  return 0;
}
0