标签:can ide math while ios P20 git pen closed
简单dp
dp[i][j]表示第i个人在j次传球前的状态
注意i=1 i=n时特殊处理
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<algorithm> using namespace std; int n,m,f[35][35]; int read() { int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if(ch==‘-‘) f=-1;ch=getchar();} while(isdigit(ch)) {x=x*10+ch-‘0‘;ch=getchar();} return x*f; } int main() { scanf("%d%d",&n,&m); f[1][0]=1; for(int i=1;i<=m;i++) { f[1][i]=f[n][i-1]+f[2][i-1]; f[n][i]=f[1][i-1]+f[n-1][i-1]; for(int j=2;j<n;j++) { f[j][i]=f[j-1][i-1]+f[j+1][i-1]; } } printf("%d",f[1][m]); }
标签:can ide math while ios P20 git pen closed
原文地址:https://www.cnblogs.com/SX0427/p/9124378.html