QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#753836#9627. 算术Bigmonster#AC ✓1ms3640kbC++233.5kb2024-11-16 13:42:532024-11-16 13:42:54

Judging History

你现在查看的是最新测评结果

  • [2024-11-16 13:42:54]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3640kb
  • [2024-11-16 13:42:53]
  • 提交

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);
    for (int i = 1; i <= 9; i++) {
        std::cin >> A[i];
    }
    while (A[1] > 0) {
        debug(A);
        int ok = 0;
        if (A[1] - 2 >= A[2]) {
            A[1] -= 2;
            A[2]++;
        } else {
            for (int i = 2; i <= 9; i++) {
                if (A[i]) {
                    A[i + 1]++;
                    A[i]--;
                    A[1]--;
                    ok = 1;
                    break;
                }
            }
            if (!ok) {
                break;
            }
        }
    }
    int ans = 1;
    for (int i = 2; i <= 10; i++) {
        Mul(ans, pow(i, A[i]));
    }
    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: 100
Accepted
time: 0ms
memory: 3612kb

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: 0
Accepted
time: 1ms
memory: 3640kb

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:

376701872
321820208
765709043
819408880
639261805
521201354
7172464
780360907
240853384
151457742
298466126
416189734
124742738
161566750
493291429
481038778
409158325
951979430
783007793
438976523
440485591
163247072
78098984
275527515
308024444
168349368
423889166
168234582
827159852
914298923
465...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

1000
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1
2 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0 0
1 0 0 1 0 0 0 0 0
1 0 0 0 1 0 0 0 0
1 0 0 0 0 1 0 0 0
1 0 0 0 0 0 1 0 0
1 0 0 0...

output:

1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
10
4
6
8
10
12
14
16
18
9
12
15
18
21
24
27
16
20
24
28
32
36
25
30
35
40
45
36
42
48
54
49
56
63
64
72
81
53234520
78732
944784
17744840
53234520
688747536
141958720
19131876
4374
9726857
668738521
35489680
11664
79851780
8748
104630853
551437603
234594227
96996101...

result:

ok 1000 lines