题解:
#include <iostream>
#include <vector>
using namespace std;
int func(int n) {
int length = 10;
std::vector<std::vector<int>> dp(n+1, std::vector<int>(length, 0));
dp[0][0] = 1;
for (int step = 1; step <= n; ++step) {
for (int j = 0; j < length; ++j) {
dp[step][j] = dp[step-1][(j-1+length)%length] + dp[step-1][(j+1)%length];
}
}
return dp[n][0];
}
int main() {
int n = 2;
cout << func(n) << endl;
}