#define PROBLEM "https://yukicoder.me/problems/no/499" #include <algorithm> #include <iostream> #include "Mylib/IO/join.cpp" #include "Mylib/Misc/convert_base.cpp" namespace hl = haar_lib; int main() { int N; std::cin >> N; auto res = hl::convert_base_to(N, 7); std::cout << hl::join(res.begin(), res.end(), "") << "\n"; return 0; }
#line 1 "test/yukicoder/499/main.test.cpp" #define PROBLEM "https://yukicoder.me/problems/no/499" #include <algorithm> #include <iostream> #line 3 "Mylib/IO/join.cpp" #include <sstream> #include <string> namespace haar_lib { template <typename Iter> std::string join(Iter first, Iter last, std::string delim = " ") { std::stringstream s; for (auto it = first; it != last; ++it) { if (it != first) s << delim; s << *it; } return s.str(); } } // namespace haar_lib #line 3 "Mylib/Misc/convert_base.cpp" #include <vector> namespace haar_lib { std::vector<int64_t> convert_base_to(int64_t val, int64_t base) { if (val == 0) return {0}; int b = std::abs(base); std::vector<int64_t> ret; while (val != 0) { int r = val % b; if (r < 0) r += b; val = (val - r) / base; ret.push_back(r); } std::reverse(ret.begin(), ret.end()); return ret; } int64_t convert_base_from(const std::vector<int64_t> &val, int64_t base) { int64_t ret = 0; for (auto it = val.begin(); it != val.end(); ++it) { (ret *= base) += *it; } return ret; } } // namespace haar_lib #line 7 "test/yukicoder/499/main.test.cpp" namespace hl = haar_lib; int main() { int N; std::cin >> N; auto res = hl::convert_base_to(N, 7); std::cout << hl::join(res.begin(), res.end(), "") << "\n"; return 0; }