forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10093.cpp
More file actions
53 lines (50 loc) · 642 Bytes
/
10093.cpp
File metadata and controls
53 lines (50 loc) · 642 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
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
int T[128] = {0};
int main()
{
int i, b, s;
char c[12000];
for (i = 0; i < 10; i++)
{
T['0' + i] = i;
}
for (i = 10; i < 36; i++)
{
T['A' + i - 10] = i;
}
for (i = 36; i < 62; i++)
{
T['a' + i - 36] = i;
}
while (scanf("%s", c) == 1)
{
for (i = 0, b = 1; c[i]; i++)
{
if (T[c[i]] > b)
{
b = T[c[i]];
}
}
for (i = s = 0; c[i]; i++)
{
s += T[c[i]];
}
for (b++; b < 63; b++)
{
if (s % (b - 1) == 0)
{
break;
}
}
if (b < 63)
{
printf("%d\n", b);
}
else
{
printf("such number is impossible!\n");
}
}
return 0;
}