-
Notifications
You must be signed in to change notification settings - Fork 0
/
417.cpp
98 lines (81 loc) · 1.31 KB
/
417.cpp
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include<stdio.h>
#include<map>
#include<string>
using namespace std;
char s[10];
int main(){
int n, i, j, k, l, p;
map<string, int> m;
string str;
int cnt = 1;
int flag;
for(i=0;i<26;i++){
s[0] ='a'+i;
s[1] = '\0';
str = string(s);
m[str] = cnt++;
}
for(i=0;i<25;i++){
for(j=i+1;j<26;j++){
s[0] = 'a' + i;
s[1] = 'a' + j;
s[2] = '\0';
str = string(s);
m[str] = cnt++;
}
}
for(i=0;i<24;i++){
for(j=i+1;j<25;j++){
for(k=j+1;k<26;k++){
s[0] = 'a' + i;
s[1] = 'a' + j;
s[2] = 'a' + k;
s[3] = '\0';
str = string(s);
m[str] = cnt++;
}
}
}
for(i=0;i<23;i++){
for(j=i+1;j<24;j++){
for(k=j+1;k<25;k++){
for(l=k+1;l<26;l++){
s[0] = 'a' + i;
s[1] = 'a' + j;
s[2] = 'a' + k;
s[3] = 'a' + l;
s[4] = '\0';
str = string(s);
m[str] = cnt++;
}
}
}
}
for(i=0;i<22;i++){
for(j=i+1;j<23;j++){
for(k=j+1;k<24;k++){
for(l=k+1;l<25;l++){
for(p=l+1;p<26;p++){
s[0] = 'a' + i;
s[1] = 'a' + j;
s[2] = 'a' + k;
s[3] = 'a' + l;
s[4] = 'a' + p;
s[5] = '\0';
str = string(s);
m[str] = cnt++;
}
}
}
}
}
while(scanf("%s",s)==1){
str = string(s);
if(m.find(s)==m.end())
printf("0\n");
else{
printf("%d\n", m[str]);
}
}
return 0;
}