-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path417.cpp
More file actions
82 lines (80 loc) · 2.27 KB
/
417.cpp
File metadata and controls
82 lines (80 loc) · 2.27 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
72
73
74
75
76
77
78
79
80
81
82
/**
* ____
* ____ ___ ____ ________ __/ __/
* / __ `__ \/ __ `/ ___/ / / / /_
* / / / / / / /_/ / / / /_/ / __/
* /_/ /_/ /_/\__,_/_/ \__,_/_/
*
* @link : https://the-redback.com
*/
#include <bits/stdc++.h>
using namespace std;
#define inf HUGE_VAL
#define mem(a, b) memset(a, b, sizeof(a))
#define mod 1000000007
#define nn 26
map<string, int> mp;
string s = "";
void go(void) {
int i, j, k, p, q, r = 1;
for (i = 0; i < nn; i++) {
s = "";
s.push_back(i + 'a');
mp[s] = r++;
}
for (i = 0; i < nn - 1; i++)
for (j = i + 1; j < nn; j++) {
s = "";
s.push_back(i + 'a');
s.push_back(j + 'a');
mp[s] = r++;
}
for (i = 0; i < nn - 2; i++)
for (j = i + 1; j < nn - 1; j++)
for (k = j + 1; k < nn; k++) {
s = "";
s.push_back(i + 'a');
s.push_back(j + 'a');
s.push_back(k + 'a');
mp[s] = r++;
}
for (i = 0; i < nn - 3; i++)
for (j = i + 1; j < nn - 2; j++)
for (k = j + 1; k < nn - 1; k++)
for (p = k + 1; p < nn; p++) {
s = "";
s.push_back(i + 'a');
s.push_back(j + 'a');
s.push_back(k + 'a');
s.push_back(p + 'a');
mp[s] = r++;
}
for (i = 0; i < nn - 4; i++)
for (j = i + 1; j < nn - 3; j++)
for (k = j + 1; k < nn - 2; k++)
for (p = k + 1; p < nn - 1; p++)
for (q = p + 1; q < nn; q++) {
s = "";
s.push_back(i + 'a');
s.push_back(j + 'a');
s.push_back(k + 'a');
s.push_back(p + 'a');
s.push_back(q + 'a');
mp[s] = r++;
}
}
int main() {
go();
char a[15];
int ret = 0;
int n, i, k, r;
int tc, t = 1;
while (gets(a)) {
s.assign(a);
if (mp.find(s) == mp.end())
printf("0\n");
else
printf("%d\n", mp[s]);
}
return 0;
}