結果

問題 No.1489 Repeat Cumulative Sum
ユーザー ytqm3
提出日時 2021-04-05 23:19:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 525 bytes
コンパイル時間 8,107 ms
コンパイル使用メモリ 251,320 KB
最終ジャッジ日時 2025-01-20 12:05:18
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
  assert(2<=N&&N<=1e5);
  assert(2<=M&&M<=1e18);
  N--;
  vector<long> A(N);
  for(int i=0;i<N;i++)
  {cin>>A[i];assert(1<=A[i]&&A[i]<=1e9);}
  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