HDU 2106 decimal system
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2106
计算一堆进制转换成10进制.
#include <iostream> #include <cmath> using namespace std; int main() { int n,a,b; char c,d; // freopen("test.txt","r",stdin); while(cin>>n) { int sum=0; while(n--) { cin>>a>>c>>b>>d; int i=0; while(a) { sum+=a%10*pow(b,i++); a/=10; } } cout<<sum<<endl; } return 0; }