QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#505307 | #9105. Zayin and Camp | PhantomThreshold | RE | 0ms | 0kb | C++17 | 867b | 2024-08-05 01:40:39 | 2024-08-05 01:40:39 |
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);
}
int fac[maxn+50];
int ifac[maxn+50];
ll C(ll n,ll m){
if (m<0 || m>n) return 0;
return 1LL*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void prepare(){
fac[0]=1;
for (int i=1;i<=maxn;i++) fac[i]=1LL*fac[i-1]*i%mod;
ifac[maxn]=inv(fac[maxn]);
for (int i=maxn-1;i>=0;i--) ifac[i]=1LL*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 T=n*(m+1)+r+s;
ll ans=1LL*C(T,n)*(r+s)%mod*inv(T)%mod;
cout << ans << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
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