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 X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
ll n, k;
int pot[1000005];
int add(int x, int y) {
if (x+y < MOD) return x+y;
return x+y-MOD;
}
int main () {
cin >> n >> k;
pot[0] = 1;
for (int i = 1; i <= n; i++) {
pot[i] = pot[i-1] * 2;
pot[i] %= MOD;
}
k--;
int br = 1;
for (int i = n-1; i >= 0; i--) {
if (k % 2 == 1) {
br = add(br, pot[i]);
}
k /= 2;
}
cout << br;
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... |