标签:
基本上和1753一样
两道题都debug了好久
1753:把65535写成了655535
2965:把65536写成了65535
尴尬.jpg
1 #include <iostream> 2 #define MAX 99999 3 using namespace std; 4 5 int main() 6 { 7 int t[16]={63624,62532,61986,61713,36744,20292,12066,7953,35064,17652,8946,4593,34959,17487,8751,4383}; 8 int x[16]={1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4}; 9 int y[16]={1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4}; 10 int n=0,ans=MAX,a,m,ans2; 11 char c; 12 13 for(int i=0;i<16;i++){ 14 15 cin>>c; 16 if (c==‘+‘) n|=(1<<(15-i)); 17 } 18 19 for(int i=0;i<65536;i++){//hehe 20 a=n;m=0; 21 for(int j=0;j<16;j++){ 22 23 if ((1<<j)&i){ 24 m++; 25 a^=t[j]; 26 } 27 } 28 if((a==0)&&(m<ans)){ 29 ans=m;ans2=i; 30 } 31 } 32 33 cout<<ans<<endl; 34 for (int i=0;i<16;i++){ 35 if((1<<i)&ans2) cout<<x[i]<<‘ ‘<<y[i]<<endl; 36 } 37 38 return 0; 39 }
标签:
原文地址:http://www.cnblogs.com/travelller/p/5727724.html