fork(1) download
  1. #include <iostream>
  2. #include<bitset>
  3. #include<math.h>
  4. #define ull unsigned long long
  5. using namespace std;
  6.  
  7. int main() {
  8. // your code goes here
  9. int t;
  10. cin>>t;
  11. while(t--)
  12. {
  13. ull n,sum=0;
  14. int count=0;
  15. cin>>n;
  16. int a[21];
  17. ull temp=n;
  18. while(temp!=0)
  19. {
  20. a[count]=temp%10;
  21. temp=temp/10;
  22. count++;
  23. }
  24. for(int i=0;i<count;i++)
  25. { sum=sum+a[i]*(pow(2,i));}
  26. sum=sum+1;
  27. ull trm=sum;
  28. int b[20];
  29. ull c1=0;
  30. while(trm!=0)
  31. {
  32. b[c1]=trm%2;
  33. trm=trm/2;
  34. c1++;
  35. }
  36. for(int i=c1-1;i>=0;i--)
  37. cout<<b[i];
  38. cout<<"\n";
  39.  
  40. }
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3300KB
stdin
6
10
100
110
1010
1
101010101010101010
stdout
11
101
111
1011
10
101010101010101011