結果

問題 No.1102 Remnants
ユーザー vjudge1
提出日時 2024-11-17 10:10:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 40,320 KB
最終ジャッジ日時 2025-02-25 05:07:33
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 3 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=5e5+5;
const int mod=998244353;
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