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;
typedef long long int ll;
#define MOD (1000000000+7)
ll fp(ll a, ll b){
ll res = 1;
while(b){
if(b&1) (res*=a)%=MOD;
(a*=a)%=MOD;
b>>=1;
}
return res;
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
ll n, k, ans=1;
cin >> n >> k;
for(ll i = n-1; i >= 0; i--){
if(k&1){
k = (k>>1) + 1;
}else{
k >>= 1;
ans += fp(2, i);
}
(ans%=MOD);
(ans+=MOD)%=MOD;
}
cout << ans;
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... |