QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#747651 | #9627. 算术 | kindow# | WA | 17ms | 3644kb | C++20 | 1.5kb | 2024-11-14 17:47:16 | 2024-11-14 17:47:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
void solve(){
vector<ll> a(10);
priority_queue<ll, vector<ll>, greater<ll>> pq;
for(ll i = 1; i <= 9; ++i){
cin >> a[i];
if(i != 1){
for(ll j = 1; j <= a[i]; ++j){
pq.push(i);
}
}
}
auto get_val = [](priority_queue<ll, vector<ll>, greater<ll>> pq) -> ll {
ll ans = 1;
while(!pq.empty()){
ans *= pq.top();
ans %= mod;
pq.pop();
}
return ans;
};
if(pq.empty() && a[1] == 1){
cout << 1 << '\n';
return;
}
if(pq.empty()){
int cur = ceil(double(a[1]) / 3.0);
int two = 3 * cur - a[1];
int th = (a[1] - two * 2) / 3;
for(int i = 1; i <= two; ++i){
pq.push(2);
}
for(int i = 1; i <= th; ++i){
pq.push(3);
}
cout << get_val(pq) << '\n';
return;
}
while(pq.top() <= 2 && a[1] >= 0){
pq.pop();
pq.push(3);
a[1]--;
}
if(a[1] == 1){
pq.push(pq.top() + 1);
pq.pop();
}
else{
int cur = ceil(double(a[1]) / 3.0);
int two = 3 * cur - a[1];
int th = (a[1] - two * 2) / 3;
for(int i = 1; i <= two; ++i){
pq.push(2);
}
for(int i = 1; i <= th; ++i){
pq.push(3);
}
}
cout << get_val(pq) << '\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll t = 1;
cin >> t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 17ms
memory: 3644kb
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:
131861263 321820208 765709043 819408880 639261805 565359709 7172464 780360907 240853384 151457742 298466126 250324849 124742738 484700250 493291429 444871981 409158325 951979430 352534673 318685216 440485591 163247072 78098984 826582545 308024444 168349368 423889166 504703746 827159852 914298923 465...
result:
wrong answer 1st lines differ - expected: '376701872', found: '131861263'