-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlockchain Hash.cpp
More file actions
49 lines (46 loc) · 851 Bytes
/
Blockchain Hash.cpp
File metadata and controls
49 lines (46 loc) · 851 Bytes
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
#include<iostream>
#include<cmath>
using namespace std;
int N,k;
long int v[100001];
void citire(){
cin>>N>>k;
for(int i=0;i<N;i++)
cin>>v[i];
}
int schimbare(int x){
int y,z,nr=0,i=0;
if(x<10)
nr=x;
else{
while(x>=10){
y=x%10;
x=x/10;
z=x%10;
nr=nr+abs(y-z)*pow(10,i);
i++;
}
}
return nr;
}
int main(){
citire();
int s=0,aux=k,max=0,x;
long int r[10001];
for(int i=0;i<N;i++){
while(aux!=0){
x=schimbare(v[i]);
s=s+x;
v[i]=x;
aux--;
}
r[i]=s;
aux=k;
s=0;
}
for(int i=0;i<N;i++)
if(r[i]>max)
max=r[i];
cout<<max<<endl;
return 0;
}