結果

問題 No.1489 Repeat Cumulative Sum
ユーザー 沙耶花沙耶花
提出日時 2021-04-23 22:20:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 838 bytes
コンパイル時間 4,382 ms
コンパイル使用メモリ 259,044 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-17 12:29:40
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 53 ms
4,380 KB
testcase_04 AC 49 ms
4,380 KB
testcase_05 AC 54 ms
4,376 KB
testcase_06 AC 45 ms
4,504 KB
testcase_07 AC 30 ms
4,376 KB
testcase_08 AC 19 ms
4,376 KB
testcase_09 AC 61 ms
4,376 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 43 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 39 ms
4,376 KB
testcase_14 AC 66 ms
4,376 KB
testcase_15 AC 63 ms
4,380 KB
testcase_16 AC 33 ms
4,380 KB
testcase_17 AC 37 ms
4,380 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 18 ms
4,376 KB
testcase_20 AC 24 ms
4,376 KB
testcase_21 AC 44 ms
4,380 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 15 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 10 ms
4,376 KB
testcase_26 AC 68 ms
4,376 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
int main(){
	
	long long N,M;
	cin>>N>>M;
	
	vector<long long> A(N,0LL);
	rep(i,N-1)cin>>A[i+1];
	
	mint cur = 1;
	int pos = -100;
	rep(i,N){
		if((N+M-1-i)%1000000007==0){
			pos = i;
			break;
		}
		cur /= N-i;
		
			
		cur *= N+M-1-i;
	}
	mint ans = 0;
	for(int i=1;i<N;i++){
		/*
		cout<<i<<','<<N+M-i<<endl;
		if(N+M-i==1000000007){
			cout<<pos<<','<<i<<endl;
		}
		*/
		if(pos!=-100){
			if(pos+1!=i){
				cur /= N+M-i;
				cur *= N+1-i;
				pos = -100;
			}
			else continue;
		}
		else{
			cur /= N+M-i;
			cur *= N+1-i;
		}
		ans += cur * A[i];
		//ans -= (M-1)*A[i];
	}
	
	cout<<ans.val()<<endl;
	
    return 0;
}
0