题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2151
package DP;
import java.util.*;
public class HDU2151 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n, p, m, t;
int arr[][];
while (sc.hasNext()) {
n = sc.nextInt();
p = sc.nextInt();
m = sc.nextInt();
t = sc.nextInt();
arr = new int[101][101];
arr[0][p] = 1;
for (int i = 1; i <= m; i++) {
for (int j = n; j >= 1; j--) {
if (j + 1 > n)
arr[i][j] += arr[i - 1][j - 1];
else if (j - 1 < 0)
arr[i][j] += arr[i - 1][j + 1];
else
arr[i][j] += (arr[i - 1][j - 1] + arr[i - 1][j + 1]);
}
}
System.out.println(arr[m][t]);
}
}
}