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 <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <bitset>
#include <math.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, k;
cin >> n >> k;
string s = bitset<10000000>(k - 1).to_string();
reverse(s.begin(), s.end());
long long pos = 1;
for(int i = 0; i < n; i++) {
if(s[i] == '1') {
pos = (pos * 2) % MOD;
}
else {
pos = (pos * 2 - 1) % MOD;
}
}
cout << pos;
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... |