[恢]hdu 2106

2011-12-20 05:34:39

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2106

题意:n个不同进制的数求和。

代码:

# include <stdio.h>


int base(int a, int b)
{
if (a == 0) return 0 ;
return b * base(a/10, b) + a%10 ;
}


int main ()
{
int n, sum, a, b ;
while (~scanf ("%d", &n))
{
sum = 0 ;
while (n--)
{
scanf ("%d(%d)", &a, &b) ;
sum += base(a,b) ;
}
printf ("%d\n", sum) ;
}
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2315260.html