Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
注意0#include <iostream> #include <cstring> #include <string> #include <stdio.h> #include <stdlib.h> #include <cmath> #include <queue> #include <algorithm> using namespace std; void print(string s){ int l = s.length(); if(l>7) cout << " ERROR"<< endl; else{ for(int i = 0; i < 7-l; i++) cout << " "; cout << s << endl; } } int tI(char c){ if(c>='0' && c<='9') return c-'0'; return c-'A'+10; } char tC(int i){ if(i<10) return i+'0'; return i-10+'A'; } string cvs(string &s, int o, int n){ int l = s.length(); long long int ans=0; for(int i = 0; i<l; i++){ ans *= o; ans += tI(s[i]); } if(ans == 0) return "0"; string res; while(ans>0){ res=tC(ans%n)+res; ans/=n; } return res; } string str; int o,n; int main() { while(cin >> str >> o >> n){ print(cvs(str,o,n)); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator