当前位置:网站首页>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 09. 用两个栈实现队列
- Sword finger offer 53 - I. find the number I in the sorted array
- Zzulioj 1673: b: clever characters???
- Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
- [sum of two numbers] 169 sum of two numbers II - enter an ordered array
- Csp-j-2020-excellent split multiple solutions
- Sword finger offer 09 Implementing queues with two stacks
- 服务熔断 Hystrix
- 第六章 数据流建模—课后习题
- 游戏商城毕业设计
猜你喜欢
随机推荐
Chapter 6 data flow modeling - after class exercises
Light a light with stm32
Web APIs DOM node
sync. Interpretation of mutex source code
【Jailhouse 文章】Look Mum, no VM Exits
剑指 Offer 53 - I. 在排序数组中查找数字 I
[merge array] 88 merge two ordered arrays
使用Electron开发桌面应用
sync.Mutex源码解读
Mysql database (I)
Service fusing hystrix
The number of enclaves
挂起等待锁 vs 自旋锁(两者的使用场合)
剑指 Offer 35.复杂链表的复制
Introduction to memory layout of FVP and Juno platforms
SAP method of modifying system table data
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
[interval problem] 435 Non overlapping interval
Sword finger offer 53 - I. find the number I in the sorted array
Zzulioj 1673: b: clever characters???









