#include<stdio.h>
int change(int val,int base)
{
int result = 0,weight = 1;
while(val){
result += (val%10)*weight;
val/=10;
weight*=base;
}
return result;
}
int main()
{
int n;
int val,base;
while(~scanf("%d",&n))
{
int sum = 0;
for(int i = 0;i<n;i++)
{
scanf("%d(%d)",&val,&base);
if(base==10) sum+=val;
else sum+=change(val,base);
}
printf("%d\n",sum);
}
return 0;
}
hdu 2106
最新推荐文章于 2017-11-20 12:29:43 发布