QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505308#9105. Zayin and CampPhantomThresholdAC ✓268ms238076kbC++17867b2024-08-05 01:41:292024-08-05 01:41:29

Judging History

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

  • [2024-08-05 01:41:29]
  • 评测
  • 测评结果:AC
  • 用时:268ms
  • 内存:238076kb
  • [2024-08-05 01:41:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=998244353;
const ll maxn=30000000;

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;	
}

詳細信息

Test #1:

score: 100
Accepted
time: 256ms
memory: 237996kb

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:

10000000
918302048
2
72
21602784
953026004
2
5
3
3
592004372

result:

ok 11 lines

Test #2:

score: 0
Accepted
time: 248ms
memory: 238012kb

input:

20
2907 1968 3465570 1924884
3380 2284 2608839 2797776
6426 1284 655387 4698365
5266 1418 2915862 996278
4240 1961 2411930 4535917
6672 326 1907300 3446892
3277 1723 2723016 2513630
3080 1642 4189797 3895123
2742 233 3735134 3357012
3979 1251 2459317 3693129
509 6365 2290345 4638974
8745 615 4764667...

output:

723781999
224712072
750599910
869276921
731158668
895479736
10881753
103229118
690899892
421944632
304404479
579383717
39487740
597221465
958692278
822467061
816115959
120618198
311959114
490554594

result:

ok 20 lines

Test #3:

score: 0
Accepted
time: 257ms
memory: 237952kb

input:

10000
3616 2765 2007646 4250422
1244 8038 1293680 1475945
4244 2356 1988338 2519904
9077 1101 2166961 4557601
7199 1389 1919122 3638263
9201 1086 2695585 641751
6551 1526 3897926 3397577
6805 1469 2840055 1196651
4369 2288 4697877 1629621
1750 5714 4059620 2520142
6405 1561 3929600 3258600
2694 3711...

output:

107534674
346132266
954157595
479052126
380877972
735381985
74839216
405232602
931302260
631564168
712648405
344937670
234651488
869142885
681927263
505369915
564524476
550870911
324659924
66948144
992964548
241231661
484506145
7718309
687385551
973923375
633803608
232509598
278238877
537450623
2945...

result:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 267ms
memory: 237932kb

input:

10000
7 1428571 3806892 3971042
5 2000000 4338289 3148090
10 1000000 3147757 839143
8 1250000 2881455 2205039
7 1428571 2342154 2438676
3 3333333 4761187 1403114
6 1666666 330504 4140769
10 1000000 3487237 481616
1 10000000 4151782 2903821
7 1428571 2563975 3328818
1 10000000 280373 4740202
7 142857...

output:

435423871
845483986
674931684
504892305
286485841
703694039
744671270
385181425
7055603
173023557
5020575
807367718
543219467
876429046
354148931
6258348
61989990
103151853
560409410
713566565
515717026
500365288
604358913
346711004
542709460
364374860
308185404
486425107
950251013
241967180
6427206...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 268ms
memory: 238076kb

input:

10000
2000000 5 234997 359032
3333333 3 3480239 397877
1428571 7 1764822 2280539
3333333 3 4283465 4449809
1428571 7 2479124 2105713
2500000 4 257363 4964607
2500000 4 210476 32336
1428571 7 3535190 64528
3333333 3 1796295 3979453
10000000 1 1300527 3139051
1111111 9 1857103 4546029
10000000 1 43260...

output:

601808266
519466734
979400098
312889390
88051123
853842460
381243056
709326067
327087381
877914126
582716530
126896771
113580723
988870074
645021596
389233843
154044915
846240727
492062144
476093414
480656293
850772851
101475207
790985572
893502279
229118932
548588503
441033211
44427859
972364425
12...

result:

ok 10000 lines