This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m;
int f[N][N];
int main() {
cin >> n >> m;
// 边界:第0次传球,第1个人获得球的机会数
f[0][1] = 1;
// 传m次球
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (j == 1)
f[i][j] = f[i - 1][j + 1] + f[i - 1][n];
else if (j == n)
f[i][j] = f[i - 1][j - 1] + f[i - 1][1];
else
f[i][j] = f[i - 1][j - 1] + f[i - 1][j + 1];
}
// 经过m次传球,球回到第1个人手中的机会数
cout << f[m][1] << endl;
return 0;