This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define len(x) ((ll) (x).size())
#define F first
#define S second
#define pb push_back
#define sep ' '
#define endl '\n'
#define Mp make_pair
#define kill(x) cout << x << '\n', exit(0);
#define set_dec(x) cout << fixed << setprecision(x);
#define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout);
const int mod = 1e9 + 7;
ll power(ll a, ll b) {
if (b == 0) return 1;
return power(a * a % mod, b / 2) * ((b & 1) ? a : 1) % mod;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
ll k;
cin >> n >> k;
k -= 1;
vector<ll> bt;
for (int j = 0; j <= 60; j++) {
if (k & (1ll << j)) bt.pb(1);
else bt.pb(0);
}
bt.resize(n);
reverse(all(bt));
ll output = 1;
for (int j = 0; j < n; j++) {
if (bt[j] == 1) {
output += power(2, j);
output %= mod;
}
}
cout << output << endl;
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... |