結果

問題 No.1856 Mex Sum 2
ユーザー 沙耶花沙耶花
提出日時 2022-02-25 22:09:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 706 ms / 3,000 ms
コード長 1,411 bytes
コンパイル時間 4,971 ms
コンパイル使用メモリ 272,384 KB
実行使用メモリ 4,552 KB
最終ジャッジ日時 2023-09-16 17:07:38
合計ジャッジ時間 25,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 5 ms
4,448 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,484 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 4 ms
4,440 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 4 ms
4,412 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 5 ms
4,384 KB
testcase_26 AC 3 ms
4,524 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 3 ms
4,380 KB
testcase_29 AC 146 ms
4,376 KB
testcase_30 AC 76 ms
4,380 KB
testcase_31 AC 140 ms
4,380 KB
testcase_32 AC 214 ms
4,404 KB
testcase_33 AC 241 ms
4,516 KB
testcase_34 AC 141 ms
4,436 KB
testcase_35 AC 79 ms
4,384 KB
testcase_36 AC 37 ms
4,380 KB
testcase_37 AC 136 ms
4,376 KB
testcase_38 AC 28 ms
4,380 KB
testcase_39 AC 4 ms
4,376 KB
testcase_40 AC 6 ms
4,380 KB
testcase_41 AC 6 ms
4,380 KB
testcase_42 AC 669 ms
4,388 KB
testcase_43 AC 567 ms
4,380 KB
testcase_44 AC 607 ms
4,376 KB
testcase_45 AC 659 ms
4,476 KB
testcase_46 AC 571 ms
4,380 KB
testcase_47 AC 616 ms
4,376 KB
testcase_48 AC 682 ms
4,480 KB
testcase_49 AC 678 ms
4,480 KB
testcase_50 AC 484 ms
4,504 KB
testcase_51 AC 704 ms
4,380 KB
testcase_52 AC 699 ms
4,380 KB
testcase_53 AC 703 ms
4,380 KB
testcase_54 AC 704 ms
4,380 KB
testcase_55 AC 706 ms
4,520 KB
testcase_56 AC 704 ms
4,380 KB
testcase_57 AC 703 ms
4,412 KB
testcase_58 AC 703 ms
4,484 KB
testcase_59 AC 703 ms
4,380 KB
testcase_60 AC 704 ms
4,400 KB
testcase_61 AC 704 ms
4,380 KB
testcase_62 AC 704 ms
4,376 KB
testcase_63 AC 705 ms
4,552 KB
testcase_64 AC 702 ms
4,380 KB
testcase_65 AC 705 ms
4,380 KB
testcase_66 AC 705 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001

struct combi{
	deque<mint> kaijou;
	deque<mint> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(kaijou[i-1]*i);
		}
		
		mint b=kaijou[n].inv();
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(kaijou_[0]*k);
		}
	}
	
	mint combination(int n,int r){
		if(r>n)return 0;
		mint a = kaijou[n]*kaijou_[r];
		a *= kaijou_[n-r];
		return a;
	}
	
	mint junretsu(int a,int b){
		mint x = kaijou_[a]*kaijou_[b];
		x *= kaijou[a+b];
		return x;
	}
	
	mint catalan(int n){
		return combination(2*n,n)/(n+1);
	}
	
};

int main(){
	
	int n,m;
	cin>>n>>m;
	
	combi C(100000);
	
	vector<mint> dp(n+1,0);
	dp[0] = 1;
	mint ans = 0;
	for(int i=1;i<=n+3;i++){
		if(i-1>m)break;
		rep(j,dp.size()){
			dp[j] *= C.kaijou_[j];
		}
		vector<mint> tdp(n+1,0);
		rep(j,n+1){
			if(j==0)continue;
			tdp[j] = C.kaijou_[j];
		}
		dp = convolution(dp,tdp);
		while(dp.size()>n+1)dp.pop_back();
		rep(j,dp.size())dp[j] *= C.kaijou[j];
		
		int tt = m+1;
		tt += max(0, m-(i+1)+1);
		rep(j,dp.size()){
			mint x = dp[j];
			x *= C.combination(n,j);
			x *= mint(tt).pow(n-j);
			x *= i;
			ans += x;
		}
	}
	cout<<ans.val()<<endl;
	
	return 0;
}
0