UVALive - 3693 Balancing the Scale

2014-11-24 08:30:38 · 作者: · 浏览: 0

题意:在给出的16个数中,求使得满足

x 1 * 4 + x 2 * 3 + x 3 * 2 + x 4 = x 5 + x 6 * 2 + x 7 * 3 + x 8 * 4 y 1 * 4 + y 2 * 3 + y 3 * 2 + y 4 = y 5 + y 6 * 2 + y 7 * 3 + y 8 * 4
这两个等式的个数有多少。

思路:状态枚举,先枚举四个数,然后查找是否有与这四个数组成的等式和的结果一样的组合,且这个组合与这四个数不相冲突,最后就是通过计算

st[i]*st[i^state]的总和就是,state表示全都有的状态

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; int a[20],num[20]; vector
       
         val[12000]; int st[1<<17]; bool judge(int x){ int cnt = 0; for (int i = 0; i < 16; i++){ if (x & (1<