1390I.cpp 509 B

12345678910111213141516171819202122232425
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. for (int n; cin >> n; ) {
  5. if (n == 0) {
  6. cout << "0-->0" << endl;
  7. continue;
  8. }
  9. cout << n << "-->";
  10. if (n < 0) {
  11. n *=- 1;
  12. cout << '-';
  13. }
  14. int m = n, k = 0;
  15. while (m) {
  16. k++;
  17. m /= 2;
  18. }
  19. for (int i = k - 1; i >= 0; i--) {
  20. cout << ((n >> i) & 1);
  21. }
  22. cout << endl;
  23. }
  24. return 0;
  25. }