5
1,0,0,0,1
0,0,0,1,1
0,1,0,1,0
1,0,0,1,1
1,0,1,0,1
开始处理 1,0,0,0,1
11000 24
开始处理 0,0,0,1,1
11000 24
开始处理 0,1,0,1,0
10100 20
开始处理 1,0,0,1,1
11100 28
开始处理 1,0,1,0,1
11010 26
122
Process finished with exit code 0
import java.util.Scanner;
import static java.lang.System.in;
/*
5
1,0,0,0,1
0,0,0,1,1
0,1,0,1,0
1,0,0,1,1
1,0,1,0,1
*/
public class test {
public static void main(String[] args) {
Scanner scanner = new Scanner(in);
String line1 = scanner.nextLine();
Integer a = Integer.valueOf(line1);
Integer res = 0;
for (int i = 0; i < a; i++) {
String line = scanner.nextLine();
Integer lineMax = getMax(line);
res += lineMax;
}
System.out.println(res);
}
private static Integer getMax(String line) {
System.out.println("开始处理 "+line);
// 1,1,0,1,1
String s = line.replaceAll(",", "");
char[] chars = s.toCharArray();
// 1,1,0,1,1
// a,b,c,d,e
// e,a,b,c,d
// d,e,a,b,c
// d,e,a,b,c
Integer max = -1;
String str = "";
for (int i = 0; i<chars.length; i++) {
// 首位是谁
int j = i;
StringBuilder sb = new StringBuilder();
for (int k = 0; k < chars.length; k++) {
sb.append(chars[j]);
j++;
j = j % chars.length;
}
Integer a = Integer.valueOf(sb.toString(), 2);
if (a > max) {
max = a;
str = sb.toString();
}
//
}
System.out.println(str+" "+max);
return max;
}
}