QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504980#9105. Zayin and CampPhantomThreshold#ML 0ms0kbC++20852b2024-08-04 17:59:372024-08-04 17:59:37

Judging History

你现在查看的是最新测评结果

  • [2024-08-04 17:59:37]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [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

result: