标签:
题意:给你n个r进制数,让你求和。
析:思路就是先转化成十进制,再加和。
代码如下:
#include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <cstring> #include <map> using namespace std; const int maxn = 70; char s[maxn]; int main(){ int n; while(~scanf("%d", &n)){ int sum = 0; while(n--){ int ss = 0; scanf("%s", s); int tt; for(tt = 0; s[tt] != ‘(‘; ++tt) ; int t = 0; for(int i = tt+1; s[i] != ‘)‘; ++i) t = t * 10 + s[i] - ‘0‘; for(int i = 0; s[i] != ‘(‘; ++i) ss = ss * t + s[i] - ‘0‘; sum += ss; } printf("%d\n", sum); } return 0; }
HDU 2106 decimal system (进制转化求和)
标签:
原文地址:http://www.cnblogs.com/dwtfukgv/p/5553849.html