简单题
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
using namespace std;
int value[300];
char st[1000000];
bool ok(int n)
{
int len = strlen(st);
for (int i = 0; i < len; i++)
if (value[st[i]] >= n)
return false;
int temp = 0;
int w = n - 1;
for (int i = 0; i < len; i++)
temp = (temp * n % w + value[st[i]] % w) % w;
return temp == 0;
}
int main()
{
//freopen("t.txt", "r", stdin);
for (char ch = '0'; ch <= '9'; ch++)
value[ch] = ch - '0';
for (char ch = 'A'; ch <= 'Z'; ch++)
value[ch] = ch - 'A' + 10;
for (char ch = 'a'; ch <= 'z'; ch++)
value[ch] = ch - 'a' + 36;
while (scanf("%s", st) != EOF)
{
int ans = -1;
for (int i = 2; i <= 62; i++)
if (ok(i))
{
ans = i;
break;
}
if (ans == -1)
printf("such number is impossible!\n");
else
printf("%d\n", ans);
}
return 0;
}