Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <math.h>
- #include <algorithm>
- using namespace std;
- string perevod(const string& s){
- vector<int> v;
- int ss = -1;
- for(auto& c: s){
- if(c - '0' > ss){
- ss = c - '0';
- }
- v.push_back(c-'0');
- }
- ss++;
- int ans = 0;
- for(int i = int(v.size()) -1 ; i >= 0; --i){
- ans += v[i] * pow(ss, int(v.size()) - i - 1);
- }
- string str = "";
- while(ans){
- str+=(ans%10 + '0');
- ans/=10;
- }
- reverse(str.begin(), str.end());
- return(str);
- }
- int main(){
- string s;
- cin>>s;
- string tmp = "";
- string cp = "";
- for(int i = 0 ; i < (int)s.size(); ++i){
- if(isdigit(s[i])){
- tmp+=s[i];
- }
- else{
- if(tmp.size()){
- auto ans = perevod(tmp);
- cp+=ans;
- }
- cp+=s[i];
- tmp = "";
- }
- }
- if(tmp.size()){
- auto ans = perevod(tmp);
- cp+=ans;
- }
- cout<<cp;
- return 0;
- }
- ///aaa010101bbb343ccc => aaa21bbb98ccc
- ///qwe136q351e53289e => qwe76q139e53289e
- ///315531e136 => 25903e76
- ///10 => 2
- ///10a => 2a
- ///aaa => aaa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement