-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP105.cpp
More file actions
76 lines (67 loc) · 1.8 KB
/
Copy pathP105.cpp
File metadata and controls
76 lines (67 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define Vector Point
typedef long long LL;
const int MAXN = 2e6 + 5;
const LL limit = 1e16 + 3;
const int MOD = 1e9 + 7;
char Inp[100];
int num[20];
int main(){
freopen("p105_sets.txt","r",stdin);
// freopen("out.txt","w",stdout);
LL ans=0;
while(~scanf("%s",Inp)){
memset(num,0,sizeof(num));
int len=strlen(Inp);
int ind=0;
for(int i=0;i<len;i++){
if(Inp[i]==',') ind++;
else
num[ind]=num[ind]*10+Inp[i]-'0';
}
int ful=(1<<(ind+1))-1;
int l,r;
bool flag=1;
for(l=1;l<ful&&flag;l++){
for(r=1;r<ful&&flag;r++){
if((l^r)==l+r){
int suml=0,ctl=0,tl=l;
int sumr=0,ctr=0,tr=r;
int id=0;
while(tl){
if(tl&1){
suml+=num[id];
ctl++;
}
tl>>=1;
id++;
}
id=0;
while(tr){
if(tr&1){
sumr+=num[id];
ctr++;
}
tr>>=1;
id++;
}
if(suml==sumr) flag=0;
if(ctl>ctr){
if(suml<=sumr) flag=0;
}
else if(ctl<ctr){
if(suml>=sumr) flag=0;
}
}
}
}
if(flag){
for(int i=0;i<=ind;i++) ans+=num[i];
}
}
cout<<ans<<endl;
return 0;
}