记录编号 |
589277 |
评测结果 |
AAAAAAAAAA |
题目名称 |
玩具 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.464 s |
提交时间 |
2024-07-04 16:34:31 |
内存使用 |
1.82 MiB |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
const int N = 210;
inline ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n;ll p,ans = 0;
ll inv[N],g[N][N];
int main(){
freopen("toyy.in","r",stdin);
freopen("toyy.out","w",stdout);
n = read(),p = read();
inv[1] = 1;
for(int i = 2;i <= n;i++)inv[i] = (p - p / i) * inv[p % i] % p;
for(int i = 0;i <= n;i++)g[0][i] = 1;
for(int i = 1;i <= n;i++)
for(int j = 1;j <= n;j++)
for(int k = 1;k <= i;k++)g[i][j] = (g[i][j] + g[i-k][j] * g[k-1][j-1] % p * inv[i] % p) % p;
for(int j = 1;j <= n;j++)ans = (ans + (ll)(g[n-1][j] - g[n-1][j-1] + p) * (ll)j % p) % p;//
printf("%lld\n",ans);
return 0;
}