-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodevitazone1q1.cpp
More file actions
55 lines (54 loc) · 1 KB
/
Copy pathcodevitazone1q1.cpp
File metadata and controls
55 lines (54 loc) · 1 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,p;
map<char,int>m;
p = 10;
for(i='A';i<='Z';i++)
{
m[i] = p;
p++;
}
int k;
string str;
// cin>>str;
// for(i=0;i<str.length();i++)
// {
// k = str[i];
// cout<<k;
// }
vector<int>v;
while(cin>>str)
{ int max=-1;
int s=0;
for(i=0;i<str.size();i++)
{
if(isdigit(str[i])!=0)
k = str[i]-48;
else
k = m[str[i]];
if(k>max)
{
max = k;
}
}
int base = max+1;
for(i=str.size()-1;i>=0;i--)
{
if(isdigit(str[i])!=0)
{
s+= (str[i]-48) * pow(base,str.size()-1-i);
}
if(isdigit(str[i])==0)
{
s+= m[str[i]] * pow(base,str.size()-1-i);
}
//cout<<s<<" ";
}//cout<<"\n";
v.push_back(s);
}
sort(v.begin(),v.end());
cout<<v[0];
return 0;
}