QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211444 | #4626. Sum Plus Product | yiyiyi# | AC ✓ | 1ms | 3796kb | C++14 | 970b | 2023-10-12 16:26:06 | 2023-10-12 16:26:06 |
Judging History
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