#include<stdio.h> #include<string.h> #include<math.h> char a[35]; /* F 15 F 14 23 11 25 13 */ int main() { long long b; while(scanf("%s",a)==1) { scanf("%lld",&b); int temp,flag=0; int n=strlen(a); for(int i=0;i<n;i++) { if(a[i]>='A'&&a[i]<='Z') a[i]=a[i]-55; else if(a[i]>='0'&&a[i]<='9') a[i]=a[i]-'0'; } for(int j=2;j<=16;j++){ long long sum=0; int abc=0; for(int i=0;i<n;i++) { if(j<=a[i]) { abc=1; break; } sum+=pow(j,n-i-1)*(int)a[i]; } if(abc) continue; if(sum==b){ flag=1; temp=j; break; } } if(flag) printf("%d\n",temp); else printf("Impossible\n"); memset(a,0,sizeof(a)); } return 0; }
05-14
352
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-03
620
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-09
08-22