QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751018 | #9627. 算术 | Dylan114514 | RE | 0ms | 0kb | C++14 | 967b | 2024-11-15 16:46:24 | 2024-11-15 16:46:26 |
answer
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define int long long
const int mod = 998244353;
int qpow(int a, int b) {
a %= mod;
int res = 1;
while (b) {
if (b & 1) {
res = (res * a) % mod;
}
a = (a * a) % mod;
b >>= 1;
}
return res % mod;
}
const int N = 0x3f3f3f3f;
int a[N], ans;
void solve() {
memset(a, 0, sizeof(a));
ans = 1;
for (int i = 1; i <= 9; ++i)
cin >> a[i];
while (a[1] >= 2 && a[1] > a[2]) {
a[1] -= 2, a[2]++;
}
for (int i = 2; i <= 9; ++i) {
if (a[1] == 0)
break;
int ad = min(a[1], a[i]);
a[1] -= ad, a[i] -= ad, a[i + 1] += ad;
}
for (int i = 1; i <= 10; ++i) {
ans %= mod;
if (a[i])
ans *= (qpow(i, a[i])) % mod;
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
7 5 3 0 0 0 0 0 0 0 4 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 2 99 88 77 66 55 44 33 22 11 100 90 80 70 60 50 40 30 20