题解 | #走方格的方案数#
走方格的方案数
https://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int dp[n+1][m+1];
for(int i=0;i<=n;i++){
dp[i][0] = 1;
}
for(int j=0;j<=m;j++){
dp[0][j] = 1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
dp[i][j] = dp[i-1][j]+dp[i][j-1];
}
}
cout << dp[n][m];
}
// 64 位输出请用 printf("%lld")
联想公司福利 1548人发布
