結果

問題 No.1102 Remnants
ユーザー lam6er
提出日時 2025-03-20 20:43:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 40,576 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-20 20:43:59
合計ジャッジ時間 1,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
int n,m,a[N],f[N],inv[N];
int read()
{
	int res,f=1;
	char ch;
	while((ch=getchar())<'0'||ch>'9')
	if(ch=='-')
	f=-1;
	res=ch^48;
	while((ch=getchar())>='0'&&ch<='9')
	res=(res<<1)+(res<<3)+(ch^48);
	return res*f;
}
int main()
{
//	freopen("ex_a4.in","r",stdin);
	int i,ans=0;
	n=read();m=read();
	for(i=1;i<=n;i++)
	a[i]=read();
	f[1]=1;inv[1]=1;
	for(i=2;i<=n;i++)
	{
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		f[i]=1ll*f[i-1]*(m+i-1)%mod*inv[i-1]%mod;
	}
	for(i=1;i<=n;i++)
	ans=(ans+1ll*a[i]*f[i]%mod*f[n+1-i]%mod)%mod;
	printf("%d",ans);
	return 0;
}
0