Advertisement
semsem_elazazy

https://codeforces.com/group/n3sTiYtHxI/contest/348734/problem/P

Feb 23rd, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. #define ll long long
  4. using namespace std;
  5.  
  6. void Base(int n){
  7.     if (n == 0)
  8.         return;
  9.      int x = n % 2;
  10.      n /= 2;
  11.      if (x < 0)
  12.         n += 1;
  13.      Base(n);
  14.      cout<< (x < 0 )? 1 : 0;
  15.      return;
  16.    
  17. }
  18.  
  19. int main() {
  20.    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  21.  
  22. int t; cin>>t;
  23. while (t--){
  24.     int n;  cin>>n;
  25.     if (n != 0)
  26.     {
  27.         Base(n);
  28.         cout<<endl;
  29.     }
  30.     else
  31.         cout<<"0"<<endl;
  32.    
  33. }
  34.     return 0;
  35. }
  36.  
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement