Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4. #include <string>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. long long x, n = 0;
  11. int k = 0;
  12. cin >> x;
  13. if (x <= 7) {
  14. cout << x;
  15. }
  16. else {
  17. while (x > 0) {
  18. if (x % 8 == 0) {
  19. k++;
  20. }
  21. n = 10 * n + (x % 8);
  22. x = (x - (x % 8)) / 8;
  23. }
  24. string s = to_string(n);
  25. reverse(s.begin(), s.end());
  26. long long Num = atoll(s.c_str());
  27. if (k > 0) {
  28. for (int i = 0; i < k; i++) {
  29. Num = Num * 10;
  30. }
  31. }
  32. cout << Num;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement