Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<string>
- #define all(container) container.begin(), container.end()
- #define fors(counter, start, finish) for (int counter = start; counter < finish; ++counter)
- #define forb(counter, start, finish) for (int counter = start; counter >= finish; --counter)
- #define vec(type) std::vector<type>
- #define dvec(type) std::vector<std::vector<type>>
- int main() {
- std::ifstream fin("input.txt");
- std::string s;
- int n;
- fin >> s >> n;
- int i = 0, a = 0;
- std::string ans;
- while (i < s.size()) {
- bool f = false;
- while (a < n && i < s.size()) {
- a *= 10; a += s[i] - '0';
- ++i;
- if (f)
- ans.push_back('0');
- f = true;
- }
- ans.push_back(a / n + '0');
- a %= n;
- }
- int idx = 0;
- while (ans[idx] == '0')
- idx++;
- std::cout << ans.size() << std::endl;
- std::cout << ans.substr(idx, ans.size() - idx) << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment