QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#612288 | #9449. New School Term | ucup-team896# | WA | 2ms | 3996kb | C++20 | 3.0kb | 2024-10-05 10:16:21 | 2024-10-05 10:16:21 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template<class T>inline void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T>inline void chkmx(T &x, T y) { if (y > x) x = y; }
using namespace std;
template <int P>
class mod_int {
using Z = mod_int;
private:
static int mo(int x) { return x < 0 ? x + P : x; }
public:
int x;
int val() const { return x; }
mod_int() : x(0) {}
template <class T>
mod_int(const T &x_) : x(x_ >= 0 && x_ < P ? static_cast<int>(x_) : mo(static_cast<int>(x_ % P))) {}
bool operator==(const Z &rhs) const { return x == rhs.x; }
bool operator!=(const Z &rhs) const { return x != rhs.x; }
Z operator-() const { return Z(x ? P - x : 0); }
Z pow(long long k) const {
Z res = 1, t = *this;
while (k) {
if (k & 1) res *= t;
if (k >>= 1) t *= t;
}
return res;
}
Z &operator++() {
x < P - 1 ? ++x : x = 0;
return *this;
}
Z &operator--() {
x ? --x : x = P - 1;
return *this;
}
Z operator++(int) {
Z ret = x;
x < P - 1 ? ++x : x = 0;
return ret;
}
Z operator--(int) {
Z ret = x;
x ? --x : x = P - 1;
return ret;
}
Z inv() const { return pow(P - 2); }
Z &operator+=(const Z &rhs) {
(x += rhs.x) >= P && (x -= P);
return *this;
}
Z &operator-=(const Z &rhs) {
(x -= rhs.x) < 0 && (x += P);
return *this;
}
Z &operator*=(const Z &rhs) {
x = 1ULL * x * rhs.x % P;
return *this;
}
Z &operator/=(const Z &rhs) { return *this *= rhs.inv(); }
#define setO(T, o) \
friend T operator o(const Z &lhs, const Z &rhs) {\
Z res = lhs; \
return res o## = rhs; \
}
setO(Z, +) setO(Z, -) setO(Z, *) setO(Z, /)
#undef setO
};
const int P = 998244353;
using Z = mod_int<P>;
struct mat {
Z a[50][50];
friend mat operator*(mat x, mat y) {
mat res;
rep (i, 0, 49) rep (k, 0, 49) {
if (!x.a[i][k].val()) continue;
rep (j, 0, 49) res.a[i][j] += x.a[i][k] * y.a[k][j];
}
return res;
}
} e, pw[30];
int id(int x, int y) {
return 7 * x + y;
}
void work() {
int n;
cin >> n;
mat res; res.a[0][id(0, 0)] = 1;
per (i, 29, 0) if (n >> i & 1) res = res * pw[i];
cout << res.a[0][id(6, 6)].val() << '\n';
}
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
rep (i, 0, 6) rep (j, 0, 6) {
e.a[id(i, j)][id(min(i + 1, 6), j)] += 1;
e.a[id(i, j)][id(i, min(j + 1, 6))] += 1;
e.a[id(i, j)][id(i, j)] += 50;
}
pw[0] = e;
rep (i, 1, 29) pw[i] = pw[i - 1] * pw[i - 1];
int t; cin >> t;
while (t--) work();
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3996kb
input:
2 4 1 3 2 4 1 4 1 2
output:
0 0
result:
wrong answer The size of S must be 2N.