Guest User

Untitled

a guest
Jul 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<cstdio>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int N,X,i,test,x,one=0;
  9. long long int zero=0;
  10.  
  11. cin>>test;
  12. for(i=1;i<=test;i++)
  13. {
  14. cin>>N>>X;
  15. x=X;
  16.  
  17. while(x!=0)
  18. {
  19. if(x%2)
  20. ++one;
  21. x=x/2;
  22. }
  23. x=X;
  24. if(!x)
  25. zero=1;
  26. else
  27. {
  28. while(1)
  29. {
  30. if(x%2)
  31. break;
  32. ++zero;
  33. x=x/2;
  34. }
  35. }
  36. if(X)
  37. zero=int( pow(2,N)-zero );
  38. else
  39. zero=1;
  40. cout<<(one+1)<<" "<<zero<<endl;
  41. one=zero=0;
  42. }
  43. cin>>test;
  44. return 0;
  45. }
Add Comment
Please, Sign In to add comment