Saleh127

UVA 679.cpp

Jul 22nd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. test
  10. {
  11. ll a,d,e,i,j,k,l;
  12. cin>>d>>i;
  13. a=1;
  14. for(j=0;j<d-1;j++)
  15. {
  16. if(i%2==0)
  17. {
  18. a=(a*2)+1;
  19. i=i/2;
  20. }
  21. else
  22. {
  23. a=(a*2);
  24. i=(i+1)/2;
  25. }
  26. }
  27. cout<<a<<endl;
  28. }
  29. ll c;
  30. cin>>c;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment