关于取模时的坑点
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod = 19980829;
ll MAXX = 0x3f3f3f3f;
int main() {
ll n; cin >> n;
bool ok = 1;
ll res = 0;
for (int i = 1; i <= n; i++) {
ll x, y; cin >> x >> y;
if (ok) {
if (res + x > res * y) {
res = res + x;
}
else res = res * y;
if (res > MAXX)ok = 0;
}
else {
res = res % mod;
if (y <= 1) {
res = (res + x) % mod;
}
else {
res = (res * y) % mod;
}
}
}
cout << res << endl;
return 0;
}
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 10, mod = 998244353;
int a[N];
void slove()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i];
int x = 0, f = 0;
for (int i = 1; i <= n; i++)
{
if (a[i])
{
if (a[i] > 1 && f)
{
x = x * a[i] % mod;
}
else
{
if (x + a[i] > 1)f = 1;
x = (x + a[i]) % mod;
}
}
}
cout << x << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
{
slove();
}
return 0;
}