The question to the problem can be found here:
Explanation:
1. Store 2 power n in a temporary variable.
2. x%y if y > x then x remains .
3. If y is smaller print x%y
4. Implement the logic. Happy Coding.
Code:
using namespace std;
#define clr(a,replace) memset(a,replace,sizeof(a))
#define INF 99999
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define PB push_back
#define MAX 100000
#define pf printf
#define sf scanf
typedef long long ll;
int main(){
//freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int n,m;
cin>>n>>m;
int res=1;
for(int i=0;i<n;i++){
res *= 2;
if(res> m){
cout<<m<<endl;
return 0;
}
}
cout<<m%res<<endl;
return 0;}
No comments:
Post a Comment