QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#113792 | #4626. Sum Plus Product | WTR2007# | AC ✓ | 1ms | 3552kb | C++20 | 865b | 2023-06-19 13:01:25 | 2023-06-19 13:01:28 |
Judging History
answer
#include<bits/stdc++.h>
#define MULT_TEST 1
#define int long long
using namespace std;
typedef array<int, 2> pii;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
inline void Solve() {
int n, ans = 0;
n = read();
ans = read();
for (int i = 2; i <= n; i++) {
int a = read();
ans = ((ans + a) % MOD + ans * a % MOD) % MOD;
}
printf("%lld\n", ans);
}
signed main() {
int T = 1;
#if MULT_TEST
T = read();
#endif
while (T--) Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
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