結果

問題 No.1102 Remnants
ユーザー yataro800yataro800
提出日時 2023-04-06 21:27:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 1,381 bytes
コンパイル時間 3,487 ms
コンパイル使用メモリ 231,552 KB
実行使用メモリ 33,024 KB
最終ジャッジ日時 2024-04-10 16:02:54
合計ジャッジ時間 6,932 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 33 ms
6,944 KB
testcase_06 AC 11 ms
6,940 KB
testcase_07 AC 277 ms
33,024 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 6 ms
6,940 KB
testcase_12 AC 10 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 25 ms
6,940 KB
testcase_15 AC 20 ms
6,940 KB
testcase_16 AC 50 ms
6,940 KB
testcase_17 AC 220 ms
28,800 KB
testcase_18 AC 254 ms
29,184 KB
testcase_19 AC 75 ms
11,904 KB
testcase_20 AC 21 ms
6,940 KB
testcase_21 AC 138 ms
18,560 KB
testcase_22 AC 203 ms
25,216 KB
testcase_23 AC 154 ms
20,224 KB
testcase_24 AC 108 ms
15,232 KB
testcase_25 AC 246 ms
29,568 KB
testcase_26 AC 12 ms
6,940 KB
testcase_27 AC 57 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <math.h>

#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using namespace atcoder;

using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

using mint = modint1000000007;
map<P_ll, mint> mp;
mint nCr(ll n, ll r) {
  P_ll key = {n, r};
  if (mp.count(key)) return mp[key];

  if (r == 0 or r == n) {
    mint mt = 1;
    return mt;
  }
  if (r == 1 or r == n - 1) {
    mint mt = n;
    return mt;
  }
  // return mp[key] = nCr(n,r-1) * (n-r+1) / r;
  return mp[key] = nCr(n - 1, r) * n / (n - r);
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  modint1000000007 ans = 0;
  for (int i = 0; i < N; i++) {
    ans += nCr(K + i, K) * nCr(N - i + K - 1, K) * A[i];
  }
  cout << ans.val() << endl;

  return 0;
}
0