# UVA 10093 An Easy Problem!
## 題目連結 [UVA 10093](https://vjudge.net/problem/UVA-10093)
### 題目內容
Have you heard the fact “The base of every normal number system is 10"? Of course, I am not talking about number systems like Stern Brockot Number System. This problem has nothing to do with this fact but may have some similarity. You will be given an N based integer number R and you are given the guaranty that R is divisible by (N − 1). You will have to print the smallest possible value for N. The range for N is 2 ≤ N ≤ 62 and the digit symbols for 62 based number is (0..9 and A..Z and a..z). Similarly, the digit symbols for 61 based number system is 0..9 and A..Z and a..y) and so on.
### 輸入限制
Each line in the input file will contain an integer (as defined in mathematics) number of any integer base (2..62). You will have to determine what is the smallest possible base of that number for the given conditions. No invalid number will be given as input.
### 輸出限制
If number with such condition is not possible output the line ‘such number is impossible!’ For each line of input there will be only a single line of output. The output will always be in decimal number system.
### 解題思路
1.長度不一定只有一個元素,所以要用getline
2.temp是算當下字元的大小,mx是所有元素中最大的字元(mx一開始設1是因為n不能小於2),因為n進制不能低於所有字元的大小,sum是計算所有字元的總和
3.continue是為了過濾掉不是0~9 、A~Z 、a~z的字元
### 程式碼
```cpp=
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
while(getline(cin,s)){
int temp=0,sum=0,mx=1;
for(int i=0;i<s.length();i++){
if(s[i]>='0' && s[i]<='9'){
temp=s[i]-'0';
}
else if(s[i]>='A' && s[i]<='Z'){
temp=s[i]-'A'+10;
}
else if(s[i]>='a' && s[i]<='z'){
temp=s[i]-'a'+36;
}
else{
continue;
}
if(temp>mx){
mx=temp;
}
sum+=temp;
}
int ty=0;
for(int i=mx+1;i<=62;i++){
if(sum%(i-1)==0){
cout<<i<<endl;
ty=1;
break;
}
}
if(ty==0){
cout<<"such number is impossible!"<<endl;
}
}
}
```
## 測資
### Sample input
3
5
A
### Sample output
4
6
11