QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#781507 | #9627. 算术 | _Strelitzia# | WA | 23ms | 3800kb | C++23 | 1.2kb | 2024-11-25 16:17:51 | 2024-11-25 16:17:56 |
Judging History
answer
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
#define int long long
#define lc (p << 1)
#define rc (p << 1 | 1)
using namespace std;
typedef pair<int, int> PII;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5, M = 1e6 + 5, INF = 0x3f3f3f3f, mod = 998244353;
int T = 1, n, m, a[N];
int calc(int x) {
int res = 1;
while(x) res *= 3, x--;
return res;
}
int get(int x) {
if (x % 3 == 0) return calc(x / 3);
else if(x % 3 == 1) {
if (x == 1) return 1;
else return 4 * calc((x - 4) / 3);
} else return 2 * calc(x / 3);
}
void solve() {
multiset<int>st;
for (int i = 1; i <= 9; i++) {
cin >> a[i];
for (int j = 1; j <= a[i] && i > 1; j++)
st.insert(i);
}
while(a[1] && st.size()) {
int x = *st.begin(), tmp = a[1] % 3;
if (a[1] >= 3) tmp += 3;
if (get(tmp) * x <= get(tmp - 1) * (x + 1)) {
a[1]--;
st.erase(st.begin());
st.insert(++x);
} else break;
}
int ans = get(a[1]) % mod;
for (auto & x: st) ans = ans * x % mod;
cout << (ans % mod + mod) % mod << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> T;
while (T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
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: 23ms
memory: 3716kb
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:
113014030 321820208 765709043 819408880 639261805 241458014 7172464 780360907 240853384 151457742 298466126 259030391 124742738 698195085 493291429 982170221 409158325 951979430 141426731 501117393 440485591 163247072 78098984 910409582 308024444 168349368 423889166 815038086 827159852 914298923 465...
result:
wrong answer 1st lines differ - expected: '376701872', found: '113014030'