-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinaryMatrix.java
More file actions
71 lines (67 loc) · 1.51 KB
/
Copy pathBinaryMatrix.java
File metadata and controls
71 lines (67 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.capillary;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BinaryMatrix {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// String nm=br.readLine();
// int n=Integer.parseInt(nm.split(" ")[0]);
// int m=Integer.parseInt(nm.split(" ")[1]);
// String a[]=new String[n];
/*for(int i=0;i<n;i++) {
a[i]=br.readLine();
}*/
// String a[]= {"1010","0100","0010","0011"};
int n=20,m=10;
String a[]={"0010101101",
"0001001101",
"0010011011",
"0000000010",
"1010010110",
"0110001011",
"1001010110",
"0011000101",
"0010100010",
"0001101110",
"0101001101",
"0010100111",
"1110000010",
"0001101110",
"0001010011",
"0111010100",
"0001000000",
"1100010001",
"1011101111",
"1101110000"};
/*int a[][]=new int[n][m];
int a[][]= {{1,0,1,0},
{0,1,0,0},
{0,0,1,0},
{0,0,1,1}
};
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
a[i][j]=Integer.parseInt(br.readLine());
}
}*/
long max=Long.MIN_VALUE;
int pos=0;
for(int i=0;i<n;i++) {
long sum=0;
int k=m-1;
for(int j=0;j<m;j++) {
if(a[i].charAt(j)=='1') {
sum=sum+(long)Math.pow(2,k);
}
k--;
}
System.out.println("sum ("+i+")= "+sum);
if(max<sum) {
max=sum;
pos=i+1;
}
}
System.out.println(pos);
}
}