結果

問題 No.1102 Remnants
ユーザー monnumonnu
提出日時 2021-04-17 23:43:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 167,404 KB
実行使用メモリ 6,228 KB
最終ジャッジ日時 2023-09-17 07:24:24
合計ジャッジ時間 4,782 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 34 ms
4,540 KB
testcase_06 AC 17 ms
4,380 KB
testcase_07 AC 112 ms
6,228 KB
testcase_08 WA -
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 32 ms
4,380 KB
testcase_16 AC 83 ms
5,908 KB
testcase_17 AC 78 ms
5,580 KB
testcase_18 AC 99 ms
5,620 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 60 ms
4,756 KB
testcase_22 AC 84 ms
5,480 KB
testcase_23 AC 65 ms
4,836 KB
testcase_24 AC 46 ms
4,492 KB
testcase_25 AC 99 ms
5,800 KB
testcase_26 AC 7 ms
4,380 KB
testcase_27 AC 27 ms
4,376 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