hdu 2106 decimal system

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,ans,len,tmp,d,t,m;
    while(~scanf("%d",&n))
    {
        ans=0;
        for(i=0;i<n;i++)
        {
            t=0;
            scanf("%d(%d)",&tmp,&d);
            t+=tmp%10;
            tmp/=10;
            m=d;
            while(tmp>0)
            {
                t+=tmp%10*m;
                m=m*d;
                tmp/=10;
            }
            ans+=t;
        }
        printf("%d
",ans);
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

原文地址:https://www.cnblogs.com/xryz/p/4848002.html