#include<iostream>#include<string>#include<cstring>#include<algorithm>using namespace std;//将N进制转成十进制long long TransFromN(string data,int n){ long long i,y,j,a[50]; long long result=0; int length=data.length(); for(i=0;i<length;i++) { if(data[i]>='0' && data[i]<='9') a[i]=data[i]-'0'; else a[i]=toupper(data[i])-'A'+10; } long long power=0; for(i=length-1;i>=0;i--) { y=1; for(j=1;j<=power;j++) y=y*n; power++; result+=y*a[i]; } return result;}int main(){ string data; int n=16; while(cin>>data) { long long result=TransFromN(data,16); cout<<result<<endl; } return 0;}
新闻热点
疑难解答