版本比较
P1164 小A点菜解
正文
增加 4 行删除 4 行
13 行未改动14151617181918192021222313 行未改动373839404141424344454646474849505113 行未改动$dp[n][m]$ 即为前 $n$ 种菜恰好凑出 $m$ 元的方案数。```cpp#include<bits/stdc++.h>using namespace std;int n,m; int a[110]; int n,m;int a[110];int dp[110][10200];int main(){ cin>>n>>m; for(int i=1;i<=n;i++){13 行未改动 dp[i][j] += dp[i-1][j-a[i]]; } } } cout<<dp[n][m]; cout<<dp[n][m]; return 0;}```
- 恰好花 $m$ 元 - 恰好花 $m$ 元$dp[i][j]$:前$i$种凑**恰好**j元的方案数$dp[0][0]=1,dp[0][j]=0 $- 花不超过$ m$ 元$dp[i][j]$:前$i$种凑 **≤j 元** 的方案数$dp[0][j]=1$