文章
6
粉丝
375
获赞
3
访问
49.2k
#include <bits/stdc++.h>
using namespace std;
bool isNum(string&s){
for(char c:s){
if(!('0'<=c&&c<='9'))return false;
}
return true;
}
int divide(vector<int>&nums,int tot){
vector<vector<int>>dp(nums.size()+1,vector<int>(tot+1,0));
for(int i=1;i<=nums.size();++i){
for(int j=0;j<=tot;++j){
dp[i][j]=dp[i-1][j];
if(j>=nums[i-1])dp[i][j]=max(dp[i][j],dp[i-1][j-nums[i-1]]+nums[i-1]);
}
}
return dp[nums.size()][tot];
}
int main(){
string str;
while(getline(cin,str)){
stringstream in(str);
string s;
vector<int>nums;
int tot=0;
bool flag=false;
while(in>>s){
//cout<<s<<endl;
if(isNum(s)){
int num=stoi(s);
nums.push_back(num);
tot+=num;
}else{
fl...
登录后发布评论
暂无评论,来抢沙发