decimal system
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3928 Accepted Submission(s): 2222
But after learning <<The Principle Of Computer>>,we know that the computer will do the calculation as the following steps:
1 computer change the 3 into binary formality like 11;
2 computer change the 9 into binary formality like 1001;
3 computer plus the two number and get the result 1100;
4 computer change the result into decimal formality like 12;
5 computer export the result;
In the computer system there are other formalities to deal with the number such as hexadecimal. Now I will give several number with a kind of change method, for example, if I give you 1011(2), it means 1011 is a number in the binary system, and 123(10) means 123 if a number in the decimal system. Now I will give you some numbers with any kind of system, you guys should tell me the sum of the number in the decimal system.
3 1(2) 2(3) 3(4) 4 11(10) 11(2) 11(3) 11(4)
6 23
简单题。
把一堆不是十进制(1~10进制)的数转化为十进制然后求和
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<cmath> #define N(n,m) memset(n,m,sizeof(n)); #define M(n,m,k) for(int n=m;n<k;n++) using namespace std; int main() { int n,a,b; __int64 sum; while(cin>>n) { sum=0; M(i,0,n) { scanf("%d(%d)",&a,&b); if(b==10) sum+=(long long)a; else { int t=0,num=0; while(a) { t+=(a%10)*pow(b,num); a/=10; num++; } sum+=(__int64)t; } } cout<<sum<<endl; } }