結果

問題 No.3004 ヤング図形
ユーザー Endered
提出日時 2025-02-04 17:59:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3,045 ms / 4,000 ms
コード長 990 bytes
コンパイル時間 4,115 ms
コンパイル使用メモリ 193,028 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-02-04 18:00:38
合計ジャッジ時間 58,543 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
ll adjust(ll n){
n %= MOD;
n += MOD;
n %= MOD;
return n;
}
ll add(ll a,ll b){
return adjust(a + b);
}
ll mul(ll a,ll b){
return adjust(a * b);
}
ll pow(ll a,ll b){
ll res = 1;
while(b > 0){
if(b % 2 == 1){
res = mul(res, a);
}
a = mul(a, a);
b /= 2;
}
return res;
}
ll inv(ll n){
return pow(n, MOD-2);
}
ll factorial(ll n){
ll res = 1;
for(ll i=2;i<=n;++i){
res = mul(res, i);
}
return res;
}
ll rect(ll h,ll w){
ll up = 1;
ll down = 1;
for(int i=1;i<=h;++i){
for(int j=0;j<w-1;++j){
up = mul(up, h * w - (i - 1) * w - 1 - j);
down = mul(down, j + 1);
}
}
return mul(up, inv(down));
}
int main(){
int k;
cin >> k;
ll ans = 1;
ll sum = 0;
for(int i=0;i<k;++i){
ll l;
ll m;
cin >> l >> m;
sum += l * m;
ans = mul(ans, rect(m,l));
ans = mul(ans, inv(factorial(l * m)));
}
ans = mul(ans, factorial(sum));
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0