fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n;
  8. cin >> n;
  9.  
  10. int bit = 0;
  11. int bit2 = 0;
  12. if( n == 0){
  13. return 1;
  14. }
  15. int i = 0;
  16.  
  17. while(n){
  18. bit = ~n & 1;
  19. bit2 += bit * pow(10, i);
  20. n = n >> 1;
  21. i++;
  22. }
  23. cout << bit2 << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5436KB
stdin
5
stdout
10