hdu 4278 2012天津赛区网络赛 数学 *
8进制转为10进制
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 const int INF=0x3f3f3f3f; 11 const double eps=1e-5; 12 typedef long long ll; 13 #define cl(a) memset(a,0,sizeof(a)) 14 #define ts printf("*****\n"); 15 const int N=1005; 16 int n,m,tt; 17 int digit[99]; 18 int main() 19 { 20 int i,j,k,ca=1; 21 #ifndef ONLINE_JUDGE 22 freopen("1.in","r",stdin); 23 #endif 24 while(scanf("%d",&n)!=EOF&&n) 25 { 26 int temp=n; 27 int len=0; 28 int sum=0; 29 while(n) 30 { 31 digit[len++]=n%10; 32 if(digit[len-1]>3&&digit[len-1]<9) digit[len-1]-=1; 33 if(digit[len-1]==9)digit[len-1]-=2; 34 n/=10; 35 } 36 for(i=len-1;i>=0;i--) 37 { 38 sum+=pow(8,i)*digit[i]; 39 } 40 printf("%d: %d\n",temp,sum); 41 } 42 }