Advertisement
TAHMID37

magex prottyoy

Oct 26th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. /*  TAHMID RAHMAN
  2.     DAMIAN FOREVER
  3.      MATH LOVER
  4.     NEVER GIVE UP
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define pi acos(-1.0)
  9. #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  10. #define ll long long
  11. #define pb push_back
  12. #define fi first
  13. #define se second
  14. #define in insert
  15. #define mp make_pair
  16. #define GCD(a,b) __gcd(a,b);
  17. #define endl "\n"
  18. #define FRU freopen("out.txt","w",stdout)
  19. #define FRO freopen("in.txt","r",stdin)
  20. #define INFLL 9223372036854775807
  21. #define debug 0
  22. #define MAXN   100001
  23. #define ar array
  24. #define lb lower_bound
  25. #define ub upper_bound
  26. const int mxN=2e5;
  27. const int MOD=1e9+7;
  28. template<typename ForwardIterator, typename T>
  29. ForwardIterator first_less_than (ForwardIterator first, ForwardIterator last, T value)
  30. {auto it = std::lower_bound (first, last, value);
  31. return (it == first ? last : --it);}
  32. bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  33. {
  34.     return (a.second < b.second);
  35. }
  36. #define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
  37. #define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
  38. bool kth_symbol(ll n,ll k)
  39. {
  40.    if(n==1)
  41.    {
  42.        return false;
  43.    }
  44.  
  45.    ll siz=powl(2,n-1);
  46.    bool ok;
  47.  
  48.    if(k<=(siz/2))
  49.    {
  50.        ok=true;
  51.    }
  52.    else
  53.    {
  54.        ok=false;
  55.        k-=(siz/2);
  56.    }
  57.  
  58.    ll temp=kth_symbol(n-1,k);
  59.  
  60.    if(ok)
  61.     return temp;
  62.    else
  63.     return !temp;
  64.  
  65.  
  66. }
  67.  
  68. int main()
  69. {
  70.     ll n,k;
  71.     cin>>n>>k;
  72.     if(kth_symbol(n,k))
  73.         cout<<1<<endl;
  74.     else
  75.         cout<<0<<endl;
  76.  
  77. }
  78.  
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement