最近水了好多简单dp。。
题意:
略
思路:
定义dp[i]:长度为i的布,最多能分的块数。
code:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+5;
int n;
int t[3];
int dp[4005];
int main() {
cin>>n;
for(int i = 0;i < 3; i++)
cin>>t[i];
for(int i = 1;i <= n; i++) {
for(int j = 0;j < 3; j++) {
if(i < t[j]) continue;
if(dp[i-t[j]] != 0 || i == t[j])
dp[i] = max(dp[i], dp[i-t[j]]+1);
}
}
cout<<dp[n]<<endl;
return 0;
}