-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10093.cpp
More file actions
37 lines (37 loc) · 1.01 KB
/
10093.cpp
File metadata and controls
37 lines (37 loc) · 1.01 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
#include <bits/stdc++.h>
using namespace std;
int main() {
char s[10000];
int i, j, k, l, n, sum, max;
while (gets(s)) {
max = 0;
sum = 0;
for (i = 0; s[i] != '\0'; i++) {
if (s[i] >= '0' && s[i] <= '9') {
sum += s[i] - '0';
if (max < s[i] - '0') max = s[i] - '0';
} else if (s[i] >= 'A' && s[i] <= 'Z') {
sum += s[i] - 'A' + 10;
if (max < s[i] - 'A' + 10) max = s[i] - 'A' + 10;
} else if (s[i] >= 'a' && s[i] <= 'z') {
sum += s[i] - 'a' + 36;
if (max < s[i] - 'a' + 36) max = s[i] - 'a' + 36;
}
}
if (max == 0)
n = 1;
else
n = max;
while (n <= 62) {
if (sum % n == 0)
break;
else
n++;
}
if (n == 63)
printf("such number is impossible!\n");
else
printf("%d\n", n + 1);
}
return 0;
}