QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#348131#4842. Rectangle PlacementWJHAC ✓0ms3748kbC++14828b2024-03-09 17:05:392024-03-09 17:05:41

Judging History

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

  • [2024-03-09 17:05:41]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3748kb
  • [2024-03-09 17:05:39]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define db long double
using namespace std;
const int N=2e5+10,mod=998244353;
int qpow(int x,int y){
	int res=1;
	while(y){
		if(y&1ll) res=res*x%mod;
		x=x*x%mod;
		y>>=1ll;
	}
	return res;
}
int C(int n,int m){
	if(n<m) return 0;
	if(m==2){
		return n*(n-1)%mod*qpow(2ll,mod-2)%mod;
	}
	if(m==3){
		return n*(n-1)%mod*(n-2)%mod*qpow(6ll,mod-2)%mod;
	}
	if(m==4){
		int e=n*(n-1)%mod*(n-2)%mod*(n-3)%mod*qpow(24ll,mod-2)%mod;
		return e;
	}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
	int n,m;cin>>n>>m;
	int ans=C(n,4ll)*C(m,4ll)%mod;
	ans=(mod-ans)%mod;
	ans=(ans+C(n,4)*((C(m,4)*6%mod+C(m,3)*6%mod+C(m,2))%mod)%mod)%mod;
	swap(n,m);
	ans=(ans+C(n,4)*((C(m,4)*6%mod+C(m,3)*6%mod+C(m,2))%mod)%mod)%mod;
	cout<<ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

4 5

output:

275

result:

ok 1 number(s): "275"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

723435135 239873451

output:

832099301

result:

ok 1 number(s): "832099301"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

10348683 1000000000

output:

959472414

result:

ok 1 number(s): "959472414"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

1000000000 886687075

output:

994294391

result:

ok 1 number(s): "994294391"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

238133469 977550485

output:

181382226

result:

ok 1 number(s): "181382226"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

895943525 1000000000

output:

574248092

result:

ok 1 number(s): "574248092"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

1000000000 772281920

output:

2306050

result:

ok 1 number(s): "2306050"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

123728314 859786182

output:

722858859

result:

ok 1 number(s): "722858859"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

76505681 1000000000

output:

94904116

result:

ok 1 number(s): "94904116"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1000000000 952844073

output:

632222340

result:

ok 1 number(s): "632222340"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

599257776 36989190

output:

592333335

result:

ok 1 number(s): "592333335"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

257067834 1000000000

output:

520152555

result:

ok 1 number(s): "520152555"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

1000000000 133406229

output:

769022397

result:

ok 1 number(s): "769022397"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

484852621 919224885

output:

829749309

result:

ok 1 number(s): "829749309"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3680kb

input:

437629987 1000000000

output:

388969627

result:

ok 1 number(s): "388969627"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

1000000000 313968382

output:

471013029

result:

ok 1 number(s): "471013029"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

665414774 326352585

output:

424688776

result:

ok 1 number(s): "424688776"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

1000000000 1000000000

output:

656213933

result:

ok 1 number(s): "656213933"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

4 4

output:

71

result:

ok 1 number(s): "71"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

4 1000000000

output:

946327704

result:

ok 1 number(s): "946327704"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1000000000 4

output:

946327704

result:

ok 1 number(s): "946327704"