设为首页 加入收藏

TOP

bnu 34988 Happy Reversal
2015-07-20 17:53:43 来源: 作者: 【 】 浏览:2
Tags:bnu 34988 Happy Reversal

Happy Reversal

Elfness is studying in an operation " NOT". For a binary number A, if we do operation " NOT A", after that, all digits of A will be reversed. (e.g. A= 1001101, after operation " NOT A", A will be 0110010). Now Elfness has N binary numbers of length K, now he can do operations " NOT" for some of his numbers. Let's assume after his operations, the maximum number is M, the minimum number is P. He wants to know what's the maximum M - P he can get. Can you help him?

Input

The first line of input is an integer T (T ≤ 60), indicating the number of cases. For each case, the first line contains 2 integers N (1 ≤ N ≤ 10000) and K (1 ≤ K ≤ 60), the next N lines contains N binary numbers, one number per line, indicating the numbers that Elfness has. The length of each binary number is K.

Output

For each case, first output the case number as "Case #x: ", and x is the case number. Then you should output an integer, indicating the maximum result that Elfness can get.

Sample Input

2
5 6
100100
001100
010001
010001
111111
5 7
0001101
0001011
0010011
0111000
1001011

Sample Output

Case #1: 51
Case #2: 103

Source

2014 ACM-ICPC Beijing Invitational Programming Contest


题解及代码:


#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; long long b_2[63]; void init() { b_2[0]=1; for(int i=1;i<=60;i++) { b_2[i]=2*b_2[i-1]; } } long long cal(char s[],int v) { long long ans=0; int len=strlen(s); int i=0; for(int i=0;i
       
        b.val; } int main() { init(); int cas,n,k; char s[64]; memset(s,0,sizeof(s)); scanf("%d",&cas); for(int ca=1;ca<=cas;ca++) { scanf("%d%d",&n,&k); for(int i=0;i
        
         




】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++中的数组array和vector,lambd.. 下一篇HDU 1978 How many ways(记忆化)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: