結果
| 問題 | No.3515 Anti EIKO |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-24 22:42:08 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 2,000 ms |
| コード長 | 9,073 bytes |
| 記録 | |
| コンパイル時間 | 5,127 ms |
| コンパイル使用メモリ | 385,064 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-04-24 22:42:26 |
| 合計ジャッジ時間 | 12,355 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace atcoder;
inline void scan(int &a) { cin >> a; }
inline void scan(unsigned int &a) { cin >> a; }
inline void scan(long long &a) { cin >> a; }
inline void scan(unsigned long long &a) { cin >> a; }
inline void scan(atcoder::modint &a) { long long x; scan(x); a = x; }
inline void scan(float &a) { cin >> a; }
inline void scan(double &a) { cin >> a; }
inline void scan(long double &a) { cin >> a; }
inline void scan(char &a) { cin >> a; }
inline void scan(string &a) { cin >> a; }
inline void scan(vector<bool> &vec) { for (int i = 0; i < int(vec.size()); i++) { int a; scan(a); vec[i] = a; } }
template<typename T> inline void scan(vector<T> &vec);
template<typename T, size_t size> inline void scan(array<T, size> &vec);
template<typename T> inline void scan(deque<T> &deq);
template<typename T, typename U> inline void scan(pair<T, U> &p);
template<typename T> inline void scan(vector<T> &vec) {
for (auto &i : vec) scan(i);
}
template<typename T, size_t size> inline void scan(array<T, size> &vec) {
for (auto &i : vec) scan(i);
}
template<typename T> inline void scan(deque<T> &deq) {
for (auto &i : deq) scan(i);
}
template<typename T, typename U> inline void scan(pair<T, U> &p) {
scan(p.first);
scan(p.second);
}
template<typename T> inline void scan(T &a) { cin >> a; }
inline void read() {}
template<typename Head, typename... Tail> inline void read(Head &head, Tail &...tail) {
scan(head);
read(tail...);
}
inline void write(const int &a) { cout << a; }
inline void write(const unsigned int &a) { cout << a; }
inline void write(const long long &a) { cout << a; }
inline void write(const unsigned long long &a) { cout << a; }
inline void write(const float &a) { cout << a; }
inline void write(const double &a) { cout << a; }
inline void write(const long double &a) { cout << a; }
inline void write(const char &a) { cout << a; }
inline void write(const string &a) { cout << a; }
template<typename T> inline void write(const vector<T> &vec);
template<typename T, size_t size> inline void write(const array<T, size> &vec);
template<typename T> inline void write(const deque<T> &deq);
template<typename T, typename U> inline void write(const pair<T, U> &p);
template<typename T> inline void write(const vector<T> &vec) {
int n = vec.size();
for (int i = 0; i < n; i++) {
if (i) write(' ');
write(vec[i]);
}
}
template<typename T, size_t size> inline void write(const array<T, size> &vec) {
int n = vec.size();
for (int i = 0; i < n; i++) {
if (i) write(' ');
write(vec[i]);
}
}
template<typename T> inline void write(const deque<T> &deq) {
int n = deq.size();
for (int i = 0; i < n; i++) {
if (i) write(' ');
write(deq[i]);
}
}
template<typename T, typename U> inline void write(const pair<T, U> &p) {
write(p.first);
write(' ');
write(p.second);
}
template<typename T> inline void write(const T &a) { cout << a; }
inline void print() { cout << '\n'; }
template<typename T> inline void print(const T &a) { write(a); cout << '\n'; }
template<typename Head, typename... Tail> inline void print(const Head &head, const Tail &...tail) {
write(head);
write(' ');
print(tail...);
}
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pq_g = priority_queue<T, vector<T>, greater<T>>;
using mint = modint998244353;
// using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end())
#define dbg(x) cerr << #x << " = " << x << endl;
#define NP next_permutation
#define endl '\n'
#define INT(...) int __VA_ARGS__; read(__VA_ARGS__);
#define LL(...) long long __VA_ARGS__; read(__VA_ARGS__);
#define ULL(...) unsigned long long __VA_ARGS__; read(__VA_ARGS__);
#define MINT(...) atcoder::modint __VA_ARGS__; read(__VA_ARGS__);
#define STR(...) string __VA_ARGS__; read(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; read(__VA_ARGS__);
#define LD(...) long double __VA_ARGS__; read(__VA_ARGS__);
#define VEC(type, name, size) vector<type> name(size); read(name);
#define VV(type, name, h, w) vector<vector<type>> name(h, vector<type>(w)); read(name);
inline void Yes(bool a = true) { cout << (a ? "Yes" : "No") << endl; }
inline void No(bool a = true) { cout << (a ? "No" : "Yes") << endl; }
inline void Takahashi(bool a = true) { cout << (a ? "Takahashi" : "Aoki") << endl; }
inline void Alice(bool a = true) { cout << (a ? "Alice" : "Bob") << endl; }
inline void Possible(bool a = true) { cout << (a ? "Possible" : "Impossible") << endl; }
constexpr int INF = 2e9;
constexpr ll LINF = 2e18;
constexpr ld pi = 3.14159265358979323846;
constexpr ld eps = 1e-9;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll modPow(ll a, ll n, ll mod = LINF) { ll ret = 1; ll x = a % mod; while (n) { if (n & 1) ret = ret * x % mod; x = x * x % mod; n >>= 1; } return ret; }
int popcount(int x) { return __builtin_popcount(x); }
ll popcount(ll x) { return __builtin_popcountll(x); }
ll isqrt(ll x) { ll n = sqrtl(x); while ((n + 1) * (n + 1) <= x) n++; while (n * n > x) n--; return n; }
template<typename T> T floor(T a, T b) { return a / b - (a % b && (a ^ b) < 0); }
template<typename T> T ceil(T a, T b) { return floor(a + b - 1, b); }
template<typename T> T bmod(T a, T b) { return a - b * floor(a, b); }
template<typename T> pair<T, T> divmod(T a, T b) { return {floor(a, b), a - b * floor(a, b)}; }
template<typename T> auto MIN(const vector<T> &a) { return *min_element(all(a)); }
template<typename T> auto MAX(const vector<T> &a) { return *max_element(all(a)); }
template<typename T> auto SUM(const vector<T> &a) { return accumulate(all(a), T(0)); }
template<typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
void cincout() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
}
template<typename T>
struct Matrix {
vector<vector<T>> A;
Matrix() = default;
Matrix(int n, int m) : A(n, vector<T>(m, T())) {}
Matrix(int n) : A(n, vector<T>(n, T())) {}
int H() const { return A.size(); }
int W() const { return A[0].size(); }
inline const vector<T> &operator[](int k) const { return A[k]; }
inline vector<T> &operator[](int k) { return A[k]; }
static Matrix I(int n) {
Matrix Mat(n);
for (int i = 0; i < n; i++) Mat[i][i] = 1;
return (Mat);
}
Matrix &operator+=(const Matrix &B) {
int n = H(), m = W();
assert(n == B.H() && m == B.W());
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
(*this)[i][j] += B[i][j];
}
}
return (*this);
}
Matrix &operator-=(const Matrix &B) {
int n = H(), m = W();
assert(n == B.H() && m == B.W());
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
(*this)[i][j] -= B[i][j];
}
}
return (*this);
}
Matrix &operator*=(const Matrix &B) {
int n = H(), m = B.W(), p = W();
assert(p == B.H());
vector<vector<T>> C(n, vector<T>(m, T()));
for (int i = 0; i < n; i++) {
for (int k = 0; k < p; k++) {
for (int j = 0; j < m; j++) {
C[i][j] += (*this)[i][k] * B[k][j];
}
}
}
A.swap(C);
return (*this);
}
Matrix &operator^=(long long k) {
Matrix B = Matrix::I(H());
while (k > 0) {
if (k & 1) B *= (*this);
(*this) *= (*this);
k >>= 1LL;
}
A.swap(B.A);
return (*this);
}
Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); }
Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); }
Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); }
Matrix operator^(const long long k) const { return (Matrix(*this) ^= k); }
};
void solve() {
LL(N, K);
mint P = mint(5).inv();
ll M = 4 * N;
Matrix<mint> Mx(M + 1, M + 1), Mt(M + 1, 1);
Mt[0][0] = 1;
for (int i = 0; i < M; i++) {
Mx[i + 1][i] += P;
if (i % 4 == 0) {
Mx[0][i] += 4 * P;
}
else {
Mx[1][i] += P;
Mx[0][i] += 3 * P;
}
}
Mx ^= K;
Mt = Mx * Mt;
mint ans = 0;
print(Mt[M][0].val());
}
int main() {
cincout();
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}