-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockchain hash.java
More file actions
34 lines (34 loc) · 1.15 KB
/
Blockchain hash.java
File metadata and controls
34 lines (34 loc) · 1.15 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
import java.util.*;
public class Eccpr{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = sc.nextInt();
ArrayList<String>list= new ArrayList<>();
for(int i=0;i<n;i++){
list.add(sc.next());
}
int max=0,suma=0;
String aux="";
for(int i=0;i<list.size();i++){
for(int j=0;j<x;j++){
if(list.get(i).length()==1){
suma+=Integer.parseInt(list.get(i));
}else{
for(int z=0;z<list.get(i).length()-1;z++){
aux+=Integer.toString(Math.abs(Character.getNumericValue(list.get(i).charAt(z))-Character.getNumericValue(list.get(i).charAt(z+1))));
}
suma+=Integer.parseInt(aux);
list.set(i,Integer.toString(Integer.parseInt(aux)));
aux="";
}
}
if(suma>max){
max=suma;
n=i;
}
suma=0;
}
System.out.println(max+" "+n);
}
}