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 ll long long
using namespace std;
const ll Mod = 1e9 + 7;
int n;
ll k;
string s;
ll pot[1000007];
ll m(ll x) {
return (x < Mod) ? x : x % Mod;
}
int main () {
cin >> n >> k;
for (int i = 0; i < n; i++) {
if (k & 1) {
s += '0';
}
else {
s += '1';
}
k = (k + 1) / 2;
}
int y = s.size();
pot[y-1] = 1;
for (int i = y-2; i >= 0; i--) {
pot[i] = m(pot[i+1] * 2);
}
ll res = 0;
for (int i = 0; i < y; i++) {
res = m(res + (s[i] - '0') * pot[i]);
}
cout << res+1;
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... |