結果
| 問題 |
No.1489 Repeat Cumulative Sum
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-04-23 21:45:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 466 bytes |
| コンパイル時間 | 829 ms |
| コンパイル使用メモリ | 73,528 KB |
| 最終ジャッジ日時 | 2025-01-20 23:44:38 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d%lld",&N,&M);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:17:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | rep(i,N-1) scanf("%d",&A[i+1]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <atcoder/modint>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using mll = atcoder::static_modint<1000000007>;
int N;
ll M;
vector<int> A;
int main(){
scanf("%d%lld",&N,&M);
A.resize(N);
rep(i,N-1) scanf("%d",&A[i+1]);
mll C = 1;
mll ans = 0;
for(int i=1; i<=N; i++){
C *= M+i-1;
C /= i;
ans += C * A[N-i];
}
printf("%u\n",ans.val());
return 0;
}
Nachia