結果
| 問題 |
No.1489 Repeat Cumulative Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-13 21:59:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 446 bytes |
| コンパイル時間 | 4,112 ms |
| コンパイル使用メモリ | 251,972 KB |
| 最終ジャッジ日時 | 2025-01-20 17:14:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 RE * 3 |
ソースコード
#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;
vector<long> A(N+1);
for(int i=2;i<=N;i++)
{cin>>A[i];}
long COM=1;
for(int i=1;i<=N-1;i++)
{COM=COM*((N+M-2-i+1)%mod)%mod;COM=COM*inv_mod(i,mod)%mod;}
for(int k=2;k<=N;k++)
{ans=(ans+A[k]*COM%mod)%mod;COM=COM*(N-k+1)%mod*inv_mod(N-k+M,mod)%mod;}
cout<<ans<<endl;
}