結果

問題 No.1489 Repeat Cumulative Sum
ユーザー ytqm3
提出日時 2021-04-05 16:48:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 449 bytes
コンパイル時間 5,726 ms
コンパイル使用メモリ 250,944 KB
最終ジャッジ日時 2025-01-20 12:00:00
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
const int mod=1000000007;

int main()
{
  long N,M,ans=0;
  cin>>N>>M;
  N--;
  vector<long> A(N);
  for(int i=0;i<N;i++)
  {cin>>A[i];}
  long COM=1;
  for(int i=1;i<=N;i++)
  {COM=COM*((N+M-1-i+1)%mod)%mod;COM=COM*inv_mod(i,mod)%mod;}
  for(int i=0;i<N;i++)
  {ans=(ans+A[i]*COM%mod)%mod;COM=COM*(N-i)%mod*inv_mod((N-i)+M-1,mod)%mod;}
  cout<<ans<<endl;
}
0