#include <stdio.h>
#include <string.h>
#define N 10000
char s[N+1];
int main()
{
int ptr, max, sum, ans, i;
while(scanf("%s", &s) == 1)
{
ptr = -1;
for(i = 0; s[i] != '\0'; i++)
{
if((s[i] != '0') && (s[i] != '+') && (s[i] != '-'))
{
ptr = i;
break;
}
}
if(ptr < 0)
{
printf("2\n");
continue;
}
max = 0, sum = 0;
for(i = ptr; s[i] != '\0'; i++)
{
if(s[i] < 65)
s[i] -= 48;
else if(s[i] < 97)
s[i] -= 55;
else
s[i] -= 61;
if(max < s[i])
max = s[i];
sum += s[i];
}
ans = 0;
for(i = max; i <= 62; i++)
{
if(!(sum % i))
{
ans = i + 1;
break;
}
}
if(ans)
printf("%d\n", ans);
else
printf("such number is impossible!\n");
}
return 0;
}
回目錄
回首頁
作者已經移除這則留言。
回覆刪除當輸入"z1"時會有不正確的輸出"63"
回覆刪除"The range for N is 2 ≤ N ≤ 62"