結果

問題 No.1489 Repeat Cumulative Sum
ユーザー ytqm3ytqm3
提出日時 2021-04-05 23:19:03
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 525 bytes
コンパイル時間 4,050 ms
コンパイル使用メモリ 261,356 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 07:39:09
合計ジャッジ時間 6,886 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 70 ms
4,380 KB
testcase_04 AC 62 ms
4,376 KB
testcase_05 AC 68 ms
4,376 KB
testcase_06 AC 59 ms
4,384 KB
testcase_07 AC 36 ms
4,380 KB
testcase_08 AC 25 ms
4,380 KB
testcase_09 AC 76 ms
4,376 KB
testcase_10 AC 67 ms
4,376 KB
testcase_11 AC 52 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 51 ms
4,376 KB
testcase_14 AC 80 ms
4,376 KB
testcase_15 AC 79 ms
4,376 KB
testcase_16 AC 43 ms
4,380 KB
testcase_17 AC 46 ms
4,376 KB
testcase_18 AC 38 ms
4,376 KB
testcase_19 AC 23 ms
4,376 KB
testcase_20 AC 31 ms
4,376 KB
testcase_21 AC 58 ms
4,376 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 12 ms
4,376 KB
testcase_26 AC 92 ms
4,376 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

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