結果

問題 No.1102 Remnants
ユーザー monnumonnu
提出日時 2021-04-17 23:49:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 166,828 KB
実行使用メモリ 6,164 KB
最終ジャッジ日時 2023-09-17 07:25:38
合計ジャッジ時間 3,887 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 65 ms
5,720 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 112 ms
6,164 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 6 ms
4,380 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 42 ms
4,380 KB
testcase_15 AC 33 ms
4,376 KB
testcase_16 AC 83 ms
6,004 KB
testcase_17 AC 78 ms
5,704 KB
testcase_18 AC 97 ms
5,660 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 59 ms
4,580 KB
testcase_22 AC 83 ms
5,444 KB
testcase_23 AC 65 ms
4,944 KB
testcase_24 AC 47 ms
4,376 KB
testcase_25 AC 99 ms
5,604 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 27 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000

ll modpow(ll a,ll x){
  ll ret=1;
  a%=MOD;
  while(x>0){
    if(x%2==1){
      ret=ret*a%MOD;
    }
    a=a*a%MOD;
    x>>=1;
  }
  return ret;
}

ll modinv(ll x){
  return modpow(x,MOD-2);
}


int main(){
  int N;
  ll K;
  cin>>N>>K;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

  /*
  if(K==0){
    ll ans=0;
    for(int i=0;i<N;i++){
      ans+=A[i];
    }
    cout<<ans<<endl;
    return 0;
  }
  */

  vector<ll> com(N+1,0);
  com[0]=1;
  for(int i=1;i<=N;i++){
    com[i]=com[i-1];
    com[i]=com[i]*(K+(ll)i)%MOD;
    com[i]=com[i]*modinv(i)%MOD;
  }
  ll ans=0;
  for(int i=0;i<N;i++){
    ll cnt=com[i]*com[N-i-1]%MOD;
    //ll cnt=COM(K+i,i)*COM(K+(N-i-1),(N-i-1))%MOD;
    ans+=A[i]*cnt;
    ans%=MOD;
  }
  cout<<ans<<endl;
}
0