程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> bnu 34988 Happy Reversal

bnu 34988 Happy Reversal

編輯:C++入門知識

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;ib.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




  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved