結果

問題 No.1100 Boxes
ユーザー batasanblog
提出日時 2025-09-09 22:36:56
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 2,960 bytes
コンパイル時間 6,506 ms
コンパイル使用メモリ 333,952 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2025-09-09 22:37:06
合計ジャッジ時間 9,222 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint=static_modint<998244353>;
//using mint = modint;
//using mint=static_modint<1000000007>;
using ll=long long;
using ull=unsigned long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);++i)
#define reps(i,s,n) for(ll i=(s);i<(ll)(n);++i)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define be(v) (v).begin(),(v).end()
const ll INF=4e18;
template<typename T>inline ll at(T&w){return w.size();}
#ifdef DEBUG
template<typename T>
void check_range(T&w,auto&&a,const source_location& l){
	if(a<0||a>=at(w)){
		cerr<<"OORange! line "<<l.line()<<" col "<<l.column()<<" index "<<a<<" size "<<w.size()<<" func "<<l.function_name()<<endl;
		assert(false);
	}
}
template<typename T>
decltype(auto)at(T&w,auto&&a,const source_location&l=source_location::current()){
	check_range(w,a,l); // if slower, delete it.
	return w[a];
}
template<typename T>
decltype(auto)at(T&w,auto&&a,auto&&b,const source_location&l=source_location::current()){
	return at(at(w,a,l),b,l);
}
template<typename T>
decltype(auto)at(T&w,auto&&a,auto&&b,auto&&c,const source_location&l=source_location::current()){
	return at(at(w,a,b,l),c,l);
}
template<typename T>
decltype(auto)at(T&w,auto&&a,auto&&b,auto&&c,auto&&d,const source_location&l=source_location::current()){
	return at(at(w,a,b,c,l),d,l);
}
template<typename T>
decltype(auto)at(T&w,pl a,const source_location&l=source_location::current()){
	return at(w,a.fi,a.se,l);
}
#else
template<typename T>inline decltype(auto)at(T&w,auto&&a){return w[a];}
template<typename T>inline decltype(auto)at(T&w,auto&&a,auto&&b){return w[a][b];}
template<typename T>inline decltype(auto)at(T&w,auto&&a,auto&&b,auto&&c){return w[a][b][c];}
template<typename T>inline decltype(auto)at(T&w,auto&&a,auto&&b,auto&&c,auto&&d){return w[a][b][c][d];}
template<typename T>inline decltype(auto)at(T&w,pl a){return w[a.fi][a.se];}
#endif
#ifdef DEBUG
#include <debug.hpp>
#else
#define show(...)
#endif

auto logic(){
	ll N,K;
	cin>>N>>K;
	vector<mint>g(K+1,1),h(K+1),nf(K+1,1);
	mint now=1;
	ll sign=-1;
	rep1(i,K){
		now*=mint(i).inv();
		at(g,i)=now*sign;
		sign=-sign;
		at(nf,i)=at(nf,i-1)*i;
		at(h,i)=mint(i).pow(N);
		at(h,i)*=at(nf,i).inv();
		show("i",i,"nf",at(nf,i));
	}
	auto f0=convolution(g,h);
	show("g",g);
	show("h",h);
	show("f0",f0);
	
	vector<mint>odd(K+1);
	for(ll i=1;i<=K;i+=2){
		at(odd,i)=mint(at(nf,i)).inv();
	}
	auto f1=convolution(f0,odd);
	mint ans=at(f1,K)*at(nf,K);
	cout<<ans.val()<<endl;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll t=1;
	//cin>>t;
	rep(i,t)logic();
	//string a;rep(i,t)logic()?a+="Yes\n":a+="No\n";cout<<a;
	//string a;rep(i,t){a+=to_string(logic())+"\n";}cout<<a;
	//string a;rep(i,t){a+=logic();}cout<<a;
	return 0;
}
//cout << fixed << setprecision(15);

0