简单dp HDU 2151

#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 105;
int dp[MAX_V][MAX_V];
int N, M, P, T;
void solve(int m, int t)
{
	dp[0][P] = 1;
	for (int i = 1; i <= M; i++)
		for (int j = 1; j <= N; j++)
			dp[i][j] = (j == 1 ? 0 : dp[i - 1][j - 1]) + (j == N ? 0 : dp[i - 1][j + 1]);
	cout << dp[M][T] << endl;
}
int main(int argc, char const *argv[])
{
	while (cin >> N >> P >> M >> T)
	{
		memset(dp, 0, sizeof(dp));
		solve(M, T);
	}
	return 0;
}

你可能感兴趣的:(简单dp HDU 2151)