QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750493#9627. 算术ucup-team1329#AC ✓1ms3824kbC++175.5kb2024-11-15 14:45:112024-11-15 14:45:13

Judging History

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

  • [2024-11-15 14:45:13]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3824kb
  • [2024-11-15 14:45:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;

const ll mod = 998244353;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};

class MOD {
   public:
    ll num, p;
    MOD()
        : num(0), p(mod) {};
    MOD(ll Num, ll P = mod)
        : num(Num % P), p(P) {};
    MOD operator+(const MOD& other) const { return MOD((num % p + other.num % p) % p, p); };
    MOD operator-(const MOD& other) const { return MOD((num % p - other.num % p + p) % p, p); };
    MOD operator*(const MOD& other) const { return MOD((num % p) * (other.num % p) % p, p); };
    MOD operator%(const MOD& other) const { return MOD(num % other.num); };
    bool operator==(const MOD& other) const { return num == other.num; };
    bool operator!=(const MOD& other) const { return num != other.num; };
    bool operator>(const MOD& other) const { return num > other.num; };
    bool operator<(const MOD& other) const { return num < other.num; };
    bool operator<=(const MOD& other) const { return num <= other.num; };
    bool operator>=(const MOD& other) const { return num >= other.num; };
    MOD max(const MOD& other) const { return num > other.num ? *this : other; };
    MOD min(const MOD& other) const { return num < other.num ? *this : other; };

    template <typename T>
    T operator%(const T& other) const { return (T)num % other; };
    template <typename T>
    T operator&(const T& other) const { return (T)num & other; };
    template <typename T>
    bool operator==(const T& other) const { return (T)num == other; };
    template <typename T>
    bool operator!=(const T& other) const { return (T)num != other; };
    template <typename T>
    bool operator>(const T& other) const { return (T)num > other; };
    template <typename T>
    bool operator<(const T& other) const { return (T)num < other; };
    template <typename T>
    bool operator<=(const T& other) const { return (T)num <= other; };
    template <typename T>
    bool operator>=(const T& other) const { return (T)num >= other; };
    template <typename T>
    T max(const T& other) const { return num > other ? (T)num : other; };
    template <typename T>
    T min(const T& other) const { return num < other ? (T)num : other; };
    ll q_pow(ll a, ll b, ll m) const {
        ll res = 1;
        while (b) {
            if (b & 1)
                res = ((res % m) * (a % m)) % m;
            b >>= 1;
            a = ((a % m) * (a % m)) % m;
        }
        return res;
    }
    ll inv(ll a, ll m) const {
        return q_pow(a, m - 2, m);
    }
    MOD operator/(const MOD& other) const { return MOD((num % p) * inv(other.num, p), p); };
    friend istream& operator>>(istream& in, MOD& a) {
        in >> a.num;
        a.num %= a.p;
        return in;
    };
    friend ostream& operator<<(ostream& out, const MOD& a) {
        out << a.num;
        return out;
    };
};

ll q_pow(ll a, ll b, ll m) {
    ll res = 1;
    while (b) {
        if (b & 1)
            res = ((res % m) * (a % m)) % m;
        b >>= 1;
        a = ((a % m) * (a % m)) % m;
    }
    return res;
}
ll inv(ll a, ll m) {
    return q_pow(a, m - 2, m);
}

void solve() {
    int n = 9;
    vector<int> f(n + 2);
    for (int i = 1; i <= 9; i++)
        cin >> f[i];
    // f[2] += f[1] / 2;

    int mi = min(f[1], f[2]);
    f[1] -= mi;
    f[2] -= mi;
    f[3] += mi;

    if (f[1]) {
        f[3] += f[1] / 3;
        f[1] = f[1] % 3;

        f[2] += f[1] / 2;
        f[1] = f[1] % 2;
    }
    if (f[1]) {
        for (int i = 2; i <= 9; i++)
            if (f[i]) {
                f[i]--;
                f[i + 1]++;
                break;
            }
    }
    // cout << f[1] << " " << f[2] << " " << f[3] << "\n";
    MOD p(1);
    for (int i = 2; i <= 10; i++) {
        if (f[i])
            p = p * q_pow(i, f[i], mod);
    }
    cout << p << "\n";
}

int main() {
    IOS int T = 1;
    cin >> T;
    while (T--)
        solve();
    return 0;
}

/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x                                                                                      o
o       _/_/_/_/                                                              _/       x
x      _/                                                                              o
o     _/_/_/_/ _/  _/_/   _/_/   _/_/_/ _/_/   _/_/_/     _/_/    _/_/_/    _/ _/   _/ x
x    _/       _/_/     _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/   _/ _/  o
o   _/       _/       _/    _/ _/   _/   _/  _/    _/ _/    _/  _/    _/  _/    _/_/   x
x  _/       _/         _/_/   _/   _/   _/  _/_/_/     _/_/ _/ _/    _/  _/      _/    o
o                                          _/                           _/      _/     x
x                                         _/                        _/_/       _/      o
o                                                                                      x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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: 0ms
memory: 3624kb

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: 3824kb

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