結果

問題 No.1100 Boxes
ユーザー shobonvipshobonvip
提出日時 2023-08-08 19:07:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,816 bytes
コンパイル時間 4,806 ms
コンパイル使用メモリ 261,072 KB
実行使用メモリ 29,180 KB
最終ジャッジ日時 2024-04-26 11:34:41
合計ジャッジ時間 8,267 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
22,016 KB
testcase_01 AC 37 ms
22,016 KB
testcase_02 AC 37 ms
21,888 KB
testcase_03 AC 37 ms
21,888 KB
testcase_04 AC 35 ms
21,888 KB
testcase_05 AC 37 ms
21,888 KB
testcase_06 AC 37 ms
22,016 KB
testcase_07 AC 36 ms
21,760 KB
testcase_08 AC 36 ms
22,016 KB
testcase_09 AC 36 ms
22,144 KB
testcase_10 AC 37 ms
22,016 KB
testcase_11 AC 36 ms
21,888 KB
testcase_12 AC 36 ms
21,760 KB
testcase_13 AC 36 ms
22,016 KB
testcase_14 AC 36 ms
21,888 KB
testcase_15 AC 36 ms
21,888 KB
testcase_16 AC 36 ms
21,760 KB
testcase_17 AC 36 ms
21,888 KB
testcase_18 AC 36 ms
21,888 KB
testcase_19 AC 38 ms
22,272 KB
testcase_20 AC 41 ms
22,472 KB
testcase_21 AC 56 ms
23,956 KB
testcase_22 AC 77 ms
26,492 KB
testcase_23 AC 56 ms
23,960 KB
testcase_24 AC 66 ms
25,232 KB
testcase_25 AC 67 ms
25,452 KB
testcase_26 AC 99 ms
28,992 KB
testcase_27 AC 78 ms
26,328 KB
testcase_28 AC 46 ms
22,868 KB
testcase_29 AC 79 ms
26,556 KB
testcase_30 AC 79 ms
26,352 KB
testcase_31 AC 52 ms
23,636 KB
testcase_32 AC 69 ms
25,652 KB
testcase_33 AC 102 ms
29,168 KB
testcase_34 AC 102 ms
29,048 KB
testcase_35 AC 37 ms
21,888 KB
testcase_36 AC 92 ms
29,180 KB
testcase_37 AC 37 ms
22,016 KB
testcase_38 AC 66 ms
25,328 KB
testcase_39 AC 99 ms
29,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

//defmodfact
const int COMinitMAX = 2345678;
mint fact[COMinitMAX+1], factinv[COMinitMAX+1];

void modfact(){
	fact[0] = 1;
	for (int i=1; i<=COMinitMAX; i++){
		fact[i] = fact[i-1] * i;
	}
	factinv[COMinitMAX] = fact[COMinitMAX].inv();
	for (int i=COMinitMAX-1; i>=0; i--){
		factinv[i] = factinv[i+1] * (i+1);
	}
}

mint cmb(int a, int b){
	if (a<b || b<0) return mint(0);
	return fact[a]*factinv[b]*factinv[a-b];
}
//--------


int main(){
	modfact();
	int n,k; cin >> n >> k;
	vector<mint> r1(k+1),r2(k+1),r3(k+1);
	mint par = 1;
	rep(i,0,k+1) {r1[i] = par * factinv[i]; par *= -1;}
	rep(i,0,k+1) r2[i] = mint(i).pow(n) * factinv[i];
	rep(i,0,k+1) if (i%2==1) r3[i] = factinv[i];
	vector<mint> f=convolution(r1,convolution(r2,r3));
	cout << (f[k]*fact[k]).val() << '\n';
}

0