제출 #1182549

#제출 시각아이디문제언어결과실행 시간메모리
1182549nevuorigVera and Modern Art (CCO17_art)C++20
0 / 25
3 ms4420 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ld long double
#define str string

#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()

#define in insert

#define fi first
#define se second

#define size size()

#define begin begin()
#define end end()
#define back back()
#define front front()
#define rend rend()
#define rbegin rbegin()


#define ret return

#define ull unsigned long long

#define all(a) a.begin , a.end

#define gcd __gcd

#define lcm(a , b) (a * b) / gcd(a , b)

#define friopen freopen ("exercise.in", "r", stdin); freopen("exercise.out", "w", stdout);

using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll mod = 1e9 + 7 , mod2 = 998244353 , N = 5e5 , inf = 1e18;
const ld esp = 0.0000001 , Pi = 3.1415926535897932384626433832795;

ll d[N + 12] , c[N + 12];

ll qpow(ll a , ll b , ll md = mod){
	a = (a + md)%md;
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = (ans*a)%md;
		}
		a = (a * a)%md;
		b>>=1;
	}
	return ans;
}

ll rec(ll x)
{
	ll ans = 1 , i;
	for (i = 2 ; i <= x ; i ++) ans = (ans * i) % mod2;
	ret ans;
}

void kol_a()
{
	ll i , j , v = 0 , a[30] = {} , ans = 1;
	for (i = 1 ; i <= 26 ; i ++)
	{
		cin >> a[i];
		v += a[i];
	}
	for (i = 0 ; i <= N ; i ++) d[i] = 0;
	d[0] = 1;
	for (i = 1 ; i <= 26 ; i ++)
	{
		if (!a[i]) continue;
		for (j = v - a[i] ; j >= 0 ; j --) d[j + a[i]] = (d[j + a[i]] + d[j]) % mod2;
	}
	ans = (((d[v / 2] * rec(v / 2)) % mod2) * rec((v + 1) / 2)) % mod2;
	for (i = 1 ; i <= 26 ; i ++) ans = (ans * qpow(rec(a[i]) , mod2 - 2 , mod2)) % mod2;
	cout << ans << '\n';
}


main()
{
	// friopen
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll _ = 1;

	cin >> _;
	
    while(_ --) kol_a();
}


/*



*/

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:91:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   91 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...