http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=18
#include <stdio.h>
#include <cmath>
int toDec(int num,int p)
{
int result = 0;
int n =0;
while(num)
{
result += num%10 * pow(p,n);
num = num /10;
n++;
}
return result;
}
int main()
{
int n;
int sum = 0;
int num,p;
while(scanf("%d",&n) != EOF) //忘了EOF,结果Time Limit Exceed
{
sum = 0;
for(int i =0;i<n;i++)
{
scanf("%d(%d)",&num,&p);
sum += toDec(num,p);
}
printf("%d\n",sum);
}
return 0;
}