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>
#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'
using namespace std;
const int MOD = 1e9+7;
ll e(ll a, ll b) {
if (!b) return 1;
ll res = e(a, b / 2);
if (b % 2)
return (res * res * a) % MOD;
return (res * res) % MOD;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n, k;
cin >> n >> k;
ll ans = 1;
for (int i = n - 1; i >= 0; --i) {
if (!(k % 2)) {
ans = (ans + e(2, i)) % MOD;
}
k = (k + 1) / 2;
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |