UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#167381#170. 数数chenqingborui21001005ms32496kbC++742b2023-01-21 12:37:352023-01-21 12:37:36

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,dp[60][60][3600],mod=998244353,ans=1,tot;
signed main()
{
    cin>>n>>m;
	if(m>n*n)
    {
        puts("0");
        return 0;
    }
	dp[0][0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
			for(int k=0;k<=n*n;k++)
			{
				int &cur=dp[i][j][k];
				if(j>=1)
					cur=(cur+dp[i-1][j-1][k])%mod;
				if(k>=i&&j<=i-1)
				{
					cur=(cur+dp[i-1][j][k-i]*j%mod)%mod;
					cur=(cur+dp[i-1][j][k-i]*(j+1)%mod)%mod;
				}
				if(k>=2*i)
					cur=(cur+dp[i-1][j+1][k-2*i]*(j+1)%mod*(j+1)%mod)%mod;
			}
	for(int i=1;i<=n;i++)
		ans=ans*i%mod;
	for(int i=m;i<=n*n;i++)
		tot=(tot+dp[n][0][i])%mod;
	cout<<ans*tot%mod;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1320kb

input:

6 25

output:

468000

result:

ok single line: '468000'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1432kb

input:

9 55

output:

94864779

result:

ok single line: '94864779'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1500kb

input:

10 70

output:

451961658

result:

ok single line: '451961658'

Test #4:

score: 10
Accepted
time: 4ms
memory: 2632kb

input:

19 188

output:

199080822

result:

ok single line: '199080822'

Test #5:

score: 10
Accepted
time: 9ms
memory: 2824kb

input:

20 233

output:

354115829

result:

ok single line: '354115829'

Test #6:

score: 10
Accepted
time: 4ms
memory: 2452kb

input:

18 200

output:

360483048

result:

ok single line: '360483048'

Test #7:

score: 10
Accepted
time: 200ms
memory: 24456kb

input:

46 1200

output:

744054009

result:

ok single line: '744054009'

Test #8:

score: 10
Accepted
time: 246ms
memory: 28160kb

input:

48 1333

output:

506724228

result:

ok single line: '506724228'

Test #9:

score: 10
Accepted
time: 275ms
memory: 32492kb

input:

50 1275

output:

263941435

result:

ok single line: '263941435'

Test #10:

score: 10
Accepted
time: 267ms
memory: 32496kb

input:

50 1800

output:

763816424

result:

ok single line: '763816424'