hdu 4278 Faulty Odometer

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4278

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;



int map1[11] = {0,1,2,0,3,4,5,6,0,7,8};

int map2[11] = {1,8,64,512,4096,32768,262144,2097152,16777216,134217728,1073741824};

int main()
{
    //freopen("E:\\acm\\input.txt","r",stdin);
    int a;
    int num;
    while(cin>>a && a){
        num = a;
        int sum = 0;
        int cnt = 0;
        while(a){
            int temp = a%10;
            a /= 10;
            sum += map1[temp] * map2[cnt++];
        }
        printf("%d: %d\n",num,sum);
    }
}
View Code

 

posted @ 2013-09-01 22:46  等待最好的两个人  阅读(87)  评论(0编辑  收藏  举报