QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#504980 | #9105. Zayin and Camp | PhantomThreshold# | ML | 0ms | 0kb | C++20 | 852b | 2024-08-04 17:59:37 | 2024-08-04 17:59:37 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const ll maxn=20000000;
inline ll ksm(ll a,ll x){
ll ret=1;
for (;x;x>>=1,a=a*a%mod) if (x&1) ret=ret*a%mod;
return ret;
}
inline ll inv(ll a){
return ksm(a,mod-2);
}
ll fac[maxn+50];
ll ifac[maxn+50];
ll C(ll n,ll m){
if (m<0 || m>n) return 0;
return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void prepare(){
fac[0]=1;
for (int i=1;i<=maxn;i++) fac[i]=fac[i-1]*i%mod;
ifac[maxn]=inv(fac[maxn]);
for (int i=maxn-1;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}
int main(){
ios_base::sync_with_stdio(false);
prepare();
int Tcase=1;
cin >> Tcase;
for (;Tcase--;){
ll n,m,r,s;
cin >> n >> m >> r >> s;
ll ans=C(n*m+n+r+s,n+1);
ans=ans*inv((n*m+r+s)%mod)%mod;
cout << ans << "\n";
}
return 0;
}
详细
Test #1:
score: 0
Memory Limit Exceeded
input:
11 1 10000000 5000000 5000000 10000000 1 5000000 4999999 1 1 1 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 65536 128 262144 262144
output:
0