QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746495#9611. 木桶效应ANIG20 367ms3724kbC++14937b2024-11-14 14:49:502024-11-14 14:49:51

Judging History

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

  • [2024-11-14 14:49:51]
  • 评测
  • 测评结果:20
  • 用时:367ms
  • 内存:3724kb
  • [2024-11-14 14:49:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=55,M=1e5+5,mods=998244353;
int pows(int a,int b){
	if(b==0)return 1;
	int res=pows(a,b>>1);
	res=res*res%mods;
	if(b&1)res=res*a%mods;
	return res;
}
int n,m,qs,f[N][N],jc[M],ny[M];
int C(int a,int b){
	if(a<0||b<0||a<b)return 0;
	return jc[a]*ny[b]%mods*ny[a-b]%mods;
}
signed main(){
	cin>>n>>m>>qs;
	jc[0]=ny[0]=1;
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%mods,ny[i]=pows(jc[i],mods-2);
	f[0][n]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=j;k++){
				int sm=0;
				for(int r=0;r<=j;r++){
					int ans=C(k,r)*pows(n-i-j+k-r,m)%mods;
					if(r&1)sm-=ans;
					else sm+=ans;
				}
				sm%=mods;
				f[i+1][j-k]+=f[i][j]*sm%mods*pows(i+1,k)%mods*C(j,k)%mods;
			}
		}
		for(int j=0;j<=n;j++){
			f[i+1][j]%=mods;
	//		cout<<i+1<<" "<<j<<" "<<f[i+1][j]<<endl;
		}
	}
	cout<<(f[n][0]+mods)%mods;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 4
Accepted
time: 0ms
memory: 3704kb

input:

5 3 0

output:

21412920

result:

ok single line: '21412920'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

5 3 2
3 4 4
2 5 3

output:

21412920

result:

wrong answer 1st lines differ - expected: '847674', found: '21412920'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 8
Accepted

Test #7:

score: 8
Accepted
time: 7ms
memory: 3652kb

input:

50 1 0

output:

263941435

result:

ok single line: '263941435'

Test #8:

score: 8
Accepted
time: 8ms
memory: 3724kb

input:

43 2 0

output:

136378346

result:

ok single line: '136378346'

Test #9:

score: 8
Accepted
time: 13ms
memory: 3532kb

input:

50 2 0

output:

489087596

result:

ok single line: '489087596'

Subtask #4:

score: 12
Accepted

Dependency #3:

100%
Accepted

Test #10:

score: 12
Accepted
time: 367ms
memory: 3568kb

input:

50 292247015 0

output:

226872193

result:

ok single line: '226872193'

Test #11:

score: 12
Accepted
time: 285ms
memory: 3580kb

input:

50 873009728 0

output:

63648791

result:

ok single line: '63648791'

Subtask #5:

score: 0
Skipped

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Skipped

Dependency #6:

0%

Subtask #8:

score: 0
Skipped

Dependency #7:

0%

Subtask #9:

score: 0
Skipped

Dependency #8:

0%