QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#751820 | #9627. 算术 | Xiaoying0418 | TL | 0ms | 0kb | C++14 | 3.3kb | 2024-11-15 20:51:56 | 2024-11-15 20:51:56 |
answer
#include<bits/stdc++.h>
#define ff first
#define ss second
#define typet typename T
#define typeu typename U
#define types typename... Ts
#define tempt template < typet >
#define tempu template < typeu >
#define temps template < types >
#define final constexpr const
tempt struct range {
T b, e;
range (T b, T e): b(b), e(e) {}
T begin() const {return b;}
T end() const {return e;}
};
tempt range<T> make_range(T b, T e) {return range <T> (b, e);}
tempt struct is_cont {
static final bool value = false;
};
tempt struct is_cont<range<T>>{
static final bool value = true;
};
temps struct is_cont<std::vector<Ts...>>{
static final bool value = true;
};
temps struct is_cont<std::set<Ts...>>{
static final bool value = true;
};
temps struct is_cont<std::map<Ts...>>{
static final bool value = true;
};
template < typet, typeu > std::ostream &
operator << (std::ostream &os, const std::pair<T, U> &p) {
return os << '<' << p.ff << ',' << p.ss << '>';
}
tempt std::enable_if_t<is_cont<T>::value, std::ostream> &
operator << (std::ostream &os, const T &c) {
auto it = c.begin();
if (it == c.end()) return os << "{}";
for (os << '{' << *it; ++it != c.end(); os << ',' << *it);
return os << '}';
}
void dbg() {std::cerr << std::endl;}
template < typet, types > void dbg(T arg, Ts... args) {
std::cerr << ' ' << arg; dbg(args...);
}
#ifndef ONLINE_JUDGE
#define debug(arg...) do {std::cerr << "["#arg"] :"; dbg(arg);} while (false)
#else
#define debug(...) do {} while (false)
#endif
using i64 = long long;
using vi = std::vector<int>;
using vl = std::vector<i64>;
using pii = std::pair<int, int>;
using vp = std::vector<pii>;
using vvi = std::vector<vi>;
#define lowbit(x) ((x) & (-x))
#define all(x) x.begin(), x.end()
#define set_all(x, y) std::memset(x, y, sizeof(x))
#define set_n(x, y, n) std::memset(x, y, sizeof(decltype(*(x))) * (n))
tempt void Min(T &x, const T &y) {if (x > y) x = y;}
tempt void Max(T &x, const T &y) {if (x < y) x = y;}
final int mod = 998244353;
inline int add(int x, int y) { return x + y < mod ? x + y : x + y - mod; }
inline int sub(int x, int y) { return x < y ? mod + x - y : x - y; }
inline int mul(i64 x, int y) { return x * y % mod; }
inline void Add(int& x, int y) { x = add(x, y); }
inline void Sub(int& x, int y) { x = sub(x, y); }
inline void Mul(int& x, int y) { x = mul(x, y); }
int pow(int x, int y) {
int z = 1;
for (; y; y /= 2) {
if (y & 1) Mul(z, x);
Mul(x, x);
}
return z;
}
void solve(int cas) {
vi A(11);
int cnt = 0;
for (int i = 1; i <= 9; i++) {
std::cin >> A[i];
}
while (A[1]) {
if (A[1] >= A[2] + 2) {
A[1] -= 2;
A[2]++;
} else {
for (int i = 2; i <= 9; i++) {
if (A[i] > 0) {
A[i + 1]++;
A[1]--;
A[i]--;
break;
}
}
}
}
debug(A);
int ans = 1;
for (int i = 2; i <= 10; i++) {
if (A[i] > 0) {
while (A[i]--) {
Mul(ans, i);
}
}
}
debug(A);
std::cout << ans << '\n';
}
signed main() {
std::cin.tie(nullptr) -> sync_with_stdio(false);
int T = 1;
std::cin >> T;
for (int cas = 1; cas <= T; cas++) {
solve(cas);
}
return 0;
}
/*
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
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