bzoj1925: [Sdoi2010]地精部落
orz神犇
#include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; int f[2][5100]; int main() { int n,mod; scanf("%d%d",&n,&mod); if(n==1){printf("1\n");return 0;} int now=1; memset(f,0,sizeof(f));f[now][1]=1%mod; for(int i=2;i<=n+1;i++) { now^=1; for(int j=1;j<=i;j++) f[now][j]=(f[now][j-1]+f[now^1][i-j+1])%mod; } printf("%d\n",f[now][n+1]*2%mod); return 0; }
pain and happy in the cruel world.