public class ACM_ICPC_TEAM {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
int M=sc.nextInt();
sc.nextLine();
String s[]=new String[N];
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++);
{
s[i]=sc.nextLine().toString();
}
}
BitSet b1=new BitSet(M);
BitSet b2=new BitSet(M);
BitSet b3=new BitSet(M);
int max=0,count=0,count1=0;
for(int i=0;i<N;i++)
{ b1=fromString(s[i]);
for(int j=i+1;j<N;j++)
{
b3=(BitSet) b1.clone();
b2=fromString(s[j]);
b3.or(b2);
count=b3.cardinality();
if(count>max)
{
max=count;
count1=1;
}
else if(count==max)
count1++;
}
}
System.out.println(count+"\n"+count1);
}
public static BitSet fromString(String s)
{
return BitSet.valueOf(new long[] { Long.parseLong(s,2) });
}
public static String toString(BitSet b)
{
return Long.toString(b.toLongArray()[0], 2);
}
}
我fromString
是给我NumberFormatException
当我通过拉赫大小的二进制串(〜500),其工作更小的长度字符串精绝。NumberFormatException的同时,从二进制字符串转换
只是猜测:你读下一个int,但数字可能会更大。 –
请编辑您的问题以包含例外的实际文本,包括堆栈跟踪。指出您发布的代码中的哪一行触发了异常。 – Kenster
请查看[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve),然后查看您的帖子。 –