#include <iostream>
using ll =long long;
using namespace std;
const ll MOD = 1e9 + 7;
ll fastP(ll a, ll p){
if (p == 0) return 1;
if (p % 2 == 0){
ll w = fastP(a, p / 2);
return (w * w) % MOD;
}
else{
return (fastP(a, p / 2) * a) % MOD;
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, k;
cin >> n >> k;
k--;
ll wynik = 0;
for (ll i = 63; i >= 0; i--){
if (k & (1LL << i)){
//cout << k << ' ' << i << ' ' << (1LL << i) << ' ' << (n - i - 1) << ' ' << fastP(2, (n - i - 1)) << '\n';
wynik += fastP(2, (n - i - 1));
wynik %= MOD;
}
}
//1 0 0 1 0
cout << (wynik + 1) % MOD << '\n';
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... |