This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
//i/o optimisations
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//data types & structures
typedef long long ll;
#define pq priority_queue
//graph structures
typedef vector<pair<ll,ll>> graph;
typedef vector<ll> nw_graph;
typedef pq<pair<ll,ll>> dij_q;
//constant values
const ll N=2e5+1;
const ll N6=1e6+1;
const ll INF=1e9+1;
const ll LOGN=18;
const ll MOD=1e9+7;
//operations
#define MID ((l+r)/2)
#define RANGE (r-l+1)
//pairs
#define f first
#define s second
//output
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
int main(){
fastio;
ll n, k;
cin>>n>>k; k--;
ll ans=1, x=1;
for(ll i=n-1; i>=0; i--){
// cout<<1<<endl;
if(k&1<<i){
ans+=x; ans%=MOD;
}
x*=2;
x%=MOD;
}
cout<<ans%MOD;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |