結果

問題 No.1102 Remnants
ユーザー 👑 kmjpkmjp
提出日時 2020-07-03 23:23:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 202,852 KB
実行使用メモリ 7,564 KB
最終ジャッジ日時 2023-10-17 06:21:54
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,688 KB
testcase_01 AC 3 ms
5,688 KB
testcase_02 AC 3 ms
5,688 KB
testcase_03 AC 2 ms
5,688 KB
testcase_04 AC 2 ms
5,688 KB
testcase_05 AC 44 ms
7,176 KB
testcase_06 AC 11 ms
6,000 KB
testcase_07 AC 64 ms
7,564 KB
testcase_08 AC 3 ms
5,728 KB
testcase_09 AC 5 ms
5,788 KB
testcase_10 AC 2 ms
5,704 KB
testcase_11 AC 4 ms
5,760 KB
testcase_12 AC 5 ms
5,800 KB
testcase_13 AC 5 ms
5,792 KB
testcase_14 AC 28 ms
6,716 KB
testcase_15 AC 22 ms
6,508 KB
testcase_16 AC 53 ms
7,368 KB
testcase_17 AC 50 ms
7,240 KB
testcase_18 AC 55 ms
7,252 KB
testcase_19 AC 20 ms
6,376 KB
testcase_20 AC 8 ms
5,896 KB
testcase_21 AC 34 ms
6,764 KB
testcase_22 AC 47 ms
6,952 KB
testcase_23 AC 37 ms
6,804 KB
testcase_24 AC 27 ms
6,640 KB
testcase_25 AC 56 ms
7,288 KB
testcase_26 AC 5 ms
5,808 KB
testcase_27 AC 16 ms
6,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[202020];
const ll mo=1000000007;

ll fact[202020];
ll factr[202020];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

//ll hcomb(int P_,int Q_) { return comb(P_+Q_-1,Q_);}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	fact[0]=factr[0]=1;
	FOR(i,N+1) {
		fact[i+1]=fact[i]*(K+i+1)%mo;
		factr[i+1]=factr[i]*(i+1)%mo;
	}
	
	
	
	ll ret=0;
	FOR(i,N) {
		cin>>A[i];
		int L=i+1;
		int R=N-i;
		ret+=fact[L-1]*fact[R-1]%mo*modpow(factr[L-1]*factr[R-1]%mo)%mo*A[i]%mo;
		
	}
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0