QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211444#4626. Sum Plus Productyiyiyi#AC ✓1ms3796kbC++14970b2023-10-12 16:26:062023-10-12 16:26:06

Judging History

你现在查看的是最新测评结果

  • [2023-10-12 16:26:06]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3796kb
  • [2023-10-12 16:26:06]
  • 提交

answer

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<bitset>
#include<set> 
#define int long long
#define lowbit(x) x&(-x)
#define mp make_pair
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define forE(i,x) for(int i=head[x];i;i=nxt[i])
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int maxn=2e5+5;
const int mod=998244353;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+(c-'0');
		c=getchar();
	}
	return x*f;
}
int T;
int a[maxn];
signed main()
{
	T=read();
	while(T--)
	{
		int n=read();
		rep(i,1,n) a[i]=read();
		rep(i,2,n) a[i]=(a[i]+a[i-1])%mod+(a[i]*a[i-1])%mod,a[i]%=mod;
		printf("%lld\n",a[n]);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3796kb

input:

20
500
732119 592443 487799 985235 815368 743444 295 298638 775259 682852 582519 959745 58200 894834 569370 811779 934590 894530 62915 824557 788216 907951 676664 158503 712163 916901 419672 787605 772426 781424 54232 249035 937144 397358 513471 866695 905096 196496 757032 651037 313683 13446 892474...

output:

114197416
917043234
544093214
401121933
778909293
664748218
176577148
573588739
287522182
393491771
106995199
907165620
901896328
869872965
856266924
464500410
563224721
217487082
379371271
77123502

result:

ok 20 lines