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),然後查看您的帖子。 –