結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー 沙耶花沙耶花
提出日時 2023-01-25 15:27:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,380 ms / 5,000 ms
コード長 2,372 bytes
コンパイル時間 5,057 ms
コンパイル使用メモリ 275,916 KB
実行使用メモリ 173,060 KB
最終ジャッジ日時 2023-09-09 02:48:04
合計ジャッジ時間 15,630 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
27,776 KB
testcase_01 AC 60 ms
27,884 KB
testcase_02 AC 61 ms
27,772 KB
testcase_03 AC 65 ms
28,412 KB
testcase_04 AC 60 ms
27,832 KB
testcase_05 AC 62 ms
27,948 KB
testcase_06 AC 61 ms
27,760 KB
testcase_07 AC 61 ms
27,836 KB
testcase_08 AC 60 ms
27,756 KB
testcase_09 AC 61 ms
27,780 KB
testcase_10 AC 61 ms
27,700 KB
testcase_11 AC 60 ms
27,988 KB
testcase_12 AC 62 ms
27,968 KB
testcase_13 AC 62 ms
27,776 KB
testcase_14 AC 61 ms
27,828 KB
testcase_15 AC 137 ms
37,116 KB
testcase_16 AC 234 ms
56,284 KB
testcase_17 AC 703 ms
94,436 KB
testcase_18 AC 717 ms
109,684 KB
testcase_19 AC 695 ms
94,236 KB
testcase_20 AC 746 ms
129,136 KB
testcase_21 AC 383 ms
68,680 KB
testcase_22 AC 744 ms
124,856 KB
testcase_23 AC 372 ms
61,624 KB
testcase_24 AC 745 ms
127,468 KB
testcase_25 AC 1,362 ms
160,704 KB
testcase_26 AC 1,380 ms
173,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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);
	}
	
};

template <class T>
vector<T> convolution_mint(vector<T> a,vector<T> b){
	
	static constexpr unsigned long long M0 = 998244353;
	static constexpr unsigned long long M1 = 754974721;
	static constexpr unsigned long long M2 = 469762049;
	
	vector<long long> aa(a.size()),bb(b.size());
	rep(i,a.size())aa[i] = a[i].val();
	rep(i,b.size())bb[i] = b[i].val();
	
	auto c0 = convolution<M0>(aa,bb);
	auto c1 = convolution<M1>(aa,bb);
	auto c2 = convolution<M2>(aa,bb);
	
	vector<mint> ret(c0.size());
	
	rep(i,c0.size()){		
		
		ret[i] += c0[i];
		
		{
			long long cur = c0[i];
			cur %= M1;
			cur = c1[i]-cur;
			if(cur<0)cur += M1;
			cur *= 416537774;
			cur %= M1;
			
			mint m = M0;
			ret[i] += m*cur;
			
			cur *= M0;
			cur += c0[i];
			cur %= M2;
			cur = c2[i] - cur;
			if(cur<0)cur += M2;
			cur *= 429847628;
			cur %= M2;
			m *= M1;
			ret[i] += m * cur;
		}
	}
	
	return ret;
}



combi C(3000000);


int main(){
	
	int X,Y,Z;
	cin>>X>>Y>>Z;
	
	if(X==0&&Y==0&&Z==0){
		cout<<1<<endl;
		return 0;
	}
	
	vector<mint> t(X+Y+Z+1);
	auto s=  t;
	for(int i=1;i<t.size();i++){
		t[i] = 1;
		t[i] *= C.junretsu(X,i-1);
		t[i] *= C.junretsu(Y,i-1);
		t[i] *= C.junretsu(Z,i-1);
		t[i] *= C.kaijou_[i];
		s[i] = C.kaijou_[i];
		if(i%2==1)s[i] *= -1;
	}
	s[0] = 1;
	/*
	rep(i,t.size()){
		cout<<t[i].val()<<','<<s[i].val()<<endl;
	}
	cout<<endl;
	*/
	mint p = 0;
	auto ans = convolution_mint(t,s);
	rep(i,X+Y+Z+1){
		ans[i] *= C.kaijou[i];
		//cout<<ans[i].val()<<endl;
		p += ans[i];
	}
	
	cout<<p.val()<<endl;
	
	return 0;
}
0