Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<string>
- using namespace std;
- int main()
- {
- string input;
- input.reserve(100000);
- while(!(cin >> input).eof())
- {
- ;
- }
- vector<int> output;
- output.reserve((input.length() / 3) + 1);
- int cnt = 0;
- int data = 0;
- string::reverse_iterator iter = input.rbegin();
- while(iter != input.rend())
- {
- if((*iter) == '1')
- {
- data += 1 << cnt;
- }
- if(cnt >= 2)
- {
- cnt = 0;
- output.push_back(data);
- data = 0;
- }
- else
- {
- ++cnt;
- }
- ++iter;
- }
- if(data != 0)
- {
- output.push_back(data);
- }
- vector<int>::reverse_iterator iter2 = output.rbegin();
- while(iter2 != output.rend())
- {
- cout << (*iter2);
- ++iter2;
- }
- cout << endl;
- output.clear();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement