hdu 1.2.8

 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 
 5 int pow(int a,int b)
 6 {
 7     int ans = 1;
 8     while(b--)
 9     {
10         ans *= a;
11     }
12     return ans;
13 
14 }
15 int main()
16 {
17     //freopen("input.txt","r",stdin);
18     int T;
19     int a,b,num,k;
20     char opl,opr;
21     while(cin>>T)
22     {
23         num = 0;
24 
25         while(T--)
26         {
27             cin>>a>>opl>>b>>opr;
28             k = 0;
29             while(a)
30             {
31                 num += a%10*pow(b,k++);
32                 a /= 10;
33             }
34 
35         }
36         cout<<num<<endl;
37     }
38     return 0;
39 }
原文地址:https://www.cnblogs.com/imLPT/p/3675975.html