fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long n;
  4. string s="";
  5. void recursion(long long n)
  6. {
  7. if(n==0) return;
  8. if(n%2==0)
  9. {
  10. s += '0';
  11. }
  12. else
  13. {
  14. s += '1';
  15. }
  16. recursion(n/2);
  17. }
  18. void input()
  19. {
  20. cin >> n;
  21. }
  22. void solve()
  23. {
  24. if(n==0)
  25. {
  26. cout << 0;
  27. return;
  28. }
  29. recursion(n);
  30. reverse(s.begin(),s.end());
  31. cout << s;
  32. }
  33. int main()
  34. {
  35. ios_base::sync_with_stdio(0);
  36. cin.tie(0);
  37. if(fopen("bin.inp","r"))
  38. {
  39. freopen("bin.inp","r",stdin);
  40. freopen("bin.out","w",stdout);
  41. }
  42. input();
  43. solve();
  44. }
  45.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty