結果
| 問題 | No.3515 Anti EIKO |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 11:59:10 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 5,332 bytes |
| 記録 | |
| コンパイル時間 | 2,815 ms |
| コンパイル使用メモリ | 346,828 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-24 20:55:41 |
| 合計ジャッジ時間 | 4,539 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll , ll>;
using vl = vector<ll> ; //1D
using vvl = vector<vl> ;//2D
using vvvl = vector<vvl> ;//3D
using vvvvl = vector<vvvl>;//4D
using vvvvvl = vector<vvvvl>;//5D
using vvvvvvl = vector<vvvvvl>;//6D
using vvvvvvvl = vector<vvvvvvl>;//7D
using vp = vector<pll> ; //1D
using vvp = vector<vp> ;//2D
using vvvp = vector<vvp> ;//3D
using vvvvp = vector<vvvp>;//4D
using vvvvvp = vector<vvvvp>;//5D
using vvvvvvp = vector<vvvvvp>;//6D
using vvvvvvvp = vector<vvvvvvp>;//7D
using vi = vector<int> ; //1D
using vvi = vector<vi> ;//2D
using vvvi = vector<vvi> ;//3D
using vvvvi = vector<vvvi>;//4D
using vvvvvi = vector<vvvvi>;//5D
using vvvvvvi = vector<vvvvvi>;//6D
using vvvvvvvi = vector<vvvvvvi>;//7D
using vb = vector<bool> ; //1D
using vvb = vector<vb> ;//2D
using vvvb = vector<vvb> ;//3D
using vvvvb = vector<vvvb>;//4D
using vvvvvb = vector<vvvvb>;//5D
using vvvvvvb = vector<vvvvvb>;//6D
using vvvvvvvb = vector<vvvvvvb>;//7D
using vs = vector<string> ; //1D
using vvs = vector<vs> ;//2D
using vvvs = vector<vvs> ;//3D
using vvvvs = vector<vvvs>;//4D
using vvvvvs = vector<vvvvs>;//5D
using vvvvvvs = vector<vvvvvs>;//6D
using vvvvvvvs = vector<vvvvvvs>;//7D
[[maybe_unused]] const ll INF = 2e18 ;
[[maybe_unused]] const ll MOD = 998244353;
#define rep(i,a,b) for(ll i=(ll)a; i<(ll)b; i++)
#define rrep(i,a,b) for(ll i=(ll)b-1; i>=(ll)a; i--)
#define all(vec1) (vec1).begin(), (vec1).end()
#define yn(b,ex) if(1){if(b)cout << "Yes" << endl;else cout << "No" << endl ;if(ex)return 0;}
#define debug(var) cerr << #var << " : " << var << endl;
//fastio
struct FastIO {
FastIO() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} fastio;
//あまり(負の数対応)
template<typename T>
T ovr(T a,T b){
T ret=a%b;
if(ret<0)ret+=b;
return ret;
}
template<typename T>
bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template<typename T>
bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
/////////main/////////
// https://tjkendev.github.io/procon-library/cpp/series/kitamasa.html
#include<atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
struct Mat {
mint a00, a01, a10, a11;
Mat operator+(const Mat& b) const {
return Mat{a00 + b.a00, a01 + b.a01, a10 + b.a10, a11 + b.a11};
}
Mat& operator+=(const Mat& b) {
a00 += b.a00;
a01 += b.a01;
a10 += b.a10;
a11 += b.a11;
return *this;
}
Mat operator*(const Mat& b) const {
return Mat{
a00 * b.a00 + a01 * b.a10,
a00 * b.a01 + a01 * b.a11,
a10 * b.a00 + a11 * b.a10,
a10 * b.a01 + a11 * b.a11
};
}
// スカラー倍
Mat operator*(const mint& k) const {
return Mat{a00 * k, a01 * k, a10 * k, a11 * k};
}
Mat& operator*=(const mint& k) {
a00 *= k;
a01 *= k;
a10 *= k;
a11 *= k;
return *this;
}
};
// 左からスカラー倍もできるように
Mat operator*(const mint& k, const Mat& a) {
return a * k;
}
struct Vec {
mint a0, a1;
Vec operator+(const Vec& b) const {
return Vec{a0 + b.a0, a1 + b.a1};
}
Vec& operator+=(const Vec& b) {
a0 += b.a0;
a1 += b.a1;
return *this;
}
// スカラー倍
Vec operator*(const mint& k) const {
return Vec{a0 * k, a1 * k};
}
Vec& operator*=(const mint& k) {
a0 *= k;
a1 *= k;
return *this;
}
};
// 左からも
Vec operator*(const mint& k, const Vec& v) {
return v * k;
}
// 行列×ベクトル
Vec operator*(const Mat& a, const Vec& b) {
return Vec{
a.a00 * b.a0 + a.a01 * b.a1,
a.a10 * b.a0 + a.a11 * b.a1
};
}
ll F;
// (0-indexed)
// a[i] = a_i, c[i] = c_i
// a_{i+k} = c_i*a_i + c_{i+1}*a_{i+1} + ... + c_{i+k-1}*a_{i+k-1}
vector<Mat> c;
vector<Vec> a;
// C(N, *) -> C(N+1, *)
void nxt(ll k, vector<Mat>&c0, vector<Mat>&c1) {
c1[0] = (c0[k-1] * c[0]);
for(ll i=0; i<k-1; ++i) {
c1[i+1] = (c0[i] + c0[k-1]*c[i+1]);
}
}
// C(N, *) -> C(2N, *)
void dbl(ll k, vector<Mat>&c0, vector<Mat>&c1) {
vector<vector<Mat>> cs(F, vector<Mat>(F));
for(ll i=0; i<k; ++i) cs[0][i] = c0[i];
for(ll i=0; i<k-1; ++i) {
nxt(k, cs[i], cs[i+1]);
}
for(ll i=0; i<k; ++i) {
c1[i] = {0,0,0,0};
for(ll j=0; j<k; ++j) {
c1[i] += cs[0][j] * cs[j][i];
}
}
}
// caluculate a_m
Vec solve(ll m, ll k) {
vector<Mat> c0(F), c1(F);
if(m == 0) {
return a[0];
}
for(ll i=0; i<k; ++i) c0[i] = {0,0,0,0};
c0[1] = {1,0,0,1};
ll p = 62;
while(((m >> --p) & 1) == 0);
while(p-- > 0) {
dbl(k, c0, c0);
if((m >> p) & 1) {
nxt(k, c0, c1);
for(ll j=0; j<k; ++j) c0[j] = c1[j];
}
}
Vec res({0,0});
for(ll i=0; i<k; ++i) {
res += c0[i]*a[i] ;
}
return res;
}
int main() {
ll N, K; cin >> N >> K;
if (K < 4 * N) {cout << 0 << endl; return 0;}
F = 4 * N - 1;
c.assign(F, {0,3,0,1}); c.back() = {4,3,1,1};
rep(i,0,F) if(i % 4 == 3) c[i] = {0,4,0,0};
a.assign(F, {0,0}); a.back() = {1,0};
auto ans = solve(K-1, F);
ans.a1 /= mint(5).pow(K);
cout << ans.a1.val() << endl;
}