QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#798886 | #9627. 算术 | asxziill | WA | 21ms | 3612kb | C++23 | 1.1kb | 2024-12-04 18:13:23 | 2024-12-04 18:13:23 |
Judging History
answer
#include <bits/stdc++.h>
using ll = long long;
constexpr int P = 998244353;
ll add(ll a, ll b) {
ll res = a + b;
return (res >= P ? res - P : res);
}
ll mul(ll a, ll b) {
return a * b % P;
}
void solve() {
std::multiset<int> set;
int cur;
for (int i = 1; i <= 9; i++) {
if (i == 1) {
std::cin >> cur;
} else {
int a;
std::cin >> a;
for (int j = 0; j < a; j++) {
set.insert(i);
}
}
}
while (cur > 0 && !set.empty() && *set.begin() == 2) {
int x = *set.begin();
set.erase(set.begin());
set.insert(x + 1);
cur--;
}
int ans = 1;
while (cur > 3) {
ans = mul(ans, 3);
cur -= 3;
}
if (cur == 1 && !set.empty()) {
int x = *set.begin();
set.erase(set.begin());
set.insert(x + 1);
}
ans = mul(ans, cur);
for (int x : set) {
ans = mul(ans, x);
}
std::cout << ans << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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
output:
54 108 1 10 90 90553232 143532368
result:
ok 7 lines
Test #2:
score: -100
Wrong Answer
time: 21ms
memory: 3612kb
input:
1000 22 80 50 23 35 71 81 70 96 40 33 36 2 51 52 96 5 32 56 35 85 13 58 80 26 14 31 60 21 8 19 79 5 94 44 33 85 55 10 59 76 98 28 22 69 14 72 40 14 100 68 5 18 69 95 42 51 0 32 97 37 34 85 54 33 18 40 34 10 72 72 68 81 47 80 23 23 68 40 3 71 58 7 36 79 89 83 5 68 16 30 3 82 79 35 28 30 55 88 17 86 2...
output:
0 321820208 765709043 819408880 639261805 0 7172464 780360907 240853384 151457742 298466126 0 124742738 0 493291429 0 409158325 951979430 0 0 440485591 163247072 78098984 0 308024444 168349368 423889166 0 827159852 914298923 465210963 368826477 0 257562137 254246394 611355081 0 0 183198908 834987450...
result:
wrong answer 1st lines differ - expected: '376701872', found: '0'