标签:NPU typedef atoi class include stream etl long line
背包
#define mm(a) memset(a,0,sizeof(a)); #define max(x,y) (x)>(y)?(x):(y) #define min(x,y) (x)<(y)?(x):(y) #define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout); #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,b,a) for(int i=(b);i>=(a);i--) #include<bits/stdc++.h> typedef long long ll; #define PII pair<ll,ll> using namespace std; const int INF=0x3f3f3f3f; const int MAXN=(int)2e5 + 5; const ll mod=1e9+7; string input,temp; vector<int>v; int n,dp[MAXN]; int main() { while (cin >> input) { // cin>>input; istringstream iss(input); v.clear(); v.push_back(0); mm(dp); int all=0; while (getline(iss, temp, ‘,‘)) { int x=atoi(temp.c_str()); v.push_back(x); all+=x; } if(all&1) { printf("false\n"); return 0; } n=v.size()-1; dp[0]=1; for(int i=1; i<=n; i++) { for(int j=all/2; j>=v[i]; j--) { dp[j]=max(dp[j],dp[j-v[i]]); } } if(dp[all/2])printf("true\n"); else printf("false\n"); } return 0; }
标签:NPU typedef atoi class include stream etl long line
原文地址:https://www.cnblogs.com/dogenya/p/10815601.html