当前位置:网站首页>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;
}
边栏推荐
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
- [allocation problem] 135 Distribute candy
- 数仓项目的集群脚本
- Annotation and reflection
- Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
- 利用HashMap实现简单缓存
- High precision subtraction
- National teacher qualification examination in the first half of 2022
- Using HashMap to realize simple cache
- [turn]: Apache Felix framework configuration properties
猜你喜欢
Palindrome (csp-s-2021-palin) solution
C language Essay 1
Fragment addition failed error lookup
剑指 Offer 06.从头到尾打印链表
Sword finger offer 05 Replace spaces
用STM32点个灯
Hang wait lock vs spin lock (where both are used)
Reader writer model
Web APIs DOM节点
National teacher qualification examination in the first half of 2022
随机推荐
A problem and solution of recording QT memory leakage
ALU逻辑运算单元
Developing desktop applications with electron
Add level control and logger level control of Solon logging plug-in
用STM32点个灯
Haut OJ 1357: lunch question (I) -- high precision multiplication
room数据库的使用
A new micro ORM open source framework
剑指 Offer 58 - II. 左旋转字符串
On-off and on-off of quality system construction
GBase数据库助力湾区数字金融发展
To the distance we have been looking for -- film review of "flying house journey"
Acwing 4301. Truncated sequence
Under the national teacher qualification certificate in the first half of 2022
Software test -- 0 sequence
Using HashMap to realize simple cache
Haut OJ 1316: sister choice buys candy III
Binary search basis
Improvement of pointnet++
Annotation and reflection