当前位置:网站首页>Educational Codeforces Round 116 (Rated for Div. 2) E. Arena
Educational Codeforces Round 116 (Rated for Div. 2) E. Arena
2022-07-05 05:31:00 【solemntee】
d p [ i ] [ j ] [ k ] dp[i][j][k] dp[i][j][k] The maximum value is i i i The length is j j j Less than j − 1 j-1 j−1 The number of is k k k individual
After considering a round, the state changes to d p [ i − ( j − 1 ) ] [ j − k ] [ . . . ] dp[i-(j-1)][j-k][...] dp[i−(j−1)][j−k][...], Therefore, the transfer is
d p [ i ] [ j ] [ k ] = ∑ ( C j k ∗ ( j − 1 ) k ∗ d p [ i − ( j − 1 ) ] [ j − k ] [ l ] ) dp[i][j][k]=\sum(C^k_j*(j-1)^k*dp[i-(j-1)][j-k][l]) dp[i][j][k]=∑(Cjk∗(j−1)k∗dp[i−(j−1)][j−k][l])
Find out k k k It has nothing to do with the transfer and scrolls directly .
#include<bits/stdc++.h>
using namespace std;
int dp[505][505];
const int mod=998244353;
long long poww(long long a,long long b)
{
long long t=1;
if(b==0)return 1;
while(b>1)
{
if(b%2==1)t=(t*a)%mod;
a=a*a%mod;
b/=2;
}
return a*t%mod;
}
long long P1[1005],P2[1005];
void init()
{
P1[0]=1;
P2[0]=1;
for(int i=1;i<=505;i++)P1[i]=(P1[i-1]*i)%mod;
for(int i=1;i<=505;i++)P2[i]=(P2[i-1]*poww(i,mod-2))%mod;
}
int main()
{
init();
int n,x;
scanf("%d%d",&n,&x);
for(int i=1;i<=x;i++)
for(int j=1;j<=n;j++)
for(int k=0;k<j;k++)
{
if(j==1)dp[i][j]+=1;
else if(j==i&&k!=j-1)continue;
else if(j>i)continue;
else
{
dp[i][j]=(dp[i][j]+poww(j-1,k)*P1[j]%mod*P2[k]%mod*P2[j-k]%mod*dp[i-j+1][j-k])%998244353;
}
}
///
// for(int i=1;i<=x;i++)
// for(int j=1;j<=n;j++)
// for(int k=0;k<j;k++)
// {
// printf("%d %d %d %lld\n",i,j,k,dp[i][j][k]);
// }
long long ans=0;
for(int i=1;i<=x;i++)
{
ans=(ans+dp[i][n])%998244353;
}
printf("%lld",((poww(x,n)-ans)%mod+mod)%mod);
return 0;
}
边栏推荐
- 剑指 Offer 53 - II. 0~n-1中缺失的数字
- Add level control and logger level control of Solon logging plug-in
- Maximum number of "balloons"
- Haut OJ 1245: large factorial of CDs --- high precision factorial
- Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
- Add level control and logger level control of Solon logging plug-in
- On-off and on-off of quality system construction
- 【ES实战】ES上的native realm安全方式使用
- What is the agile proportion of PMP Exam? Dispel doubts
- Solution to the palindrome string (Luogu p5041 haoi2009)
猜你喜欢
Sword finger offer 06 Print linked list from beginning to end
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
National teacher qualification examination in the first half of 2022
SAP-修改系统表数据的方法
Pointnet++的改进
Yolov5 ajouter un mécanisme d'attention
Little known skills of Task Manager
Double pointer Foundation
A misunderstanding about the console window
剑指 Offer 09. 用两个栈实现队列
随机推荐
Haut OJ 1221: a tired day
每日一题-无重复字符的最长子串
Daily question - Search two-dimensional matrix PS two-dimensional array search
Light a light with stm32
The number of enclaves
游戏商城毕业设计
On-off and on-off of quality system construction
National teacher qualification examination in the first half of 2022
Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
Little known skills of Task Manager
剑指 Offer 06.从头到尾打印链表
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
Add level control and logger level control of Solon logging plug-in
[to be continued] [UE4 notes] L3 import resources and project migration
二十六、文件系统API(设备在应用间的共享;目录和文件API)
The present is a gift from heaven -- a film review of the journey of the soul
对象的序列化
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
Graduation project of game mall
Haut OJ 1241: League activities of class XXX