This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
`-/oo+/- ``
.oyhhhhhhyo.`od
+hhhhyyoooos. h/
+hhyso++oosy- /s
.yoooossyyo:``-y`
..----.` ``.-/+:.`
`````..-::/.
`..```.-::///`
`-.....--::::/:
`.......--::////:
`...`....---:::://:
`......``..--:::::///:`
`---.......--:::::////+/`
----------::::::/::///++:
----:---:::::///////////:`
.----::::::////////////:-`
`----::::::::::/::::::::-
`.-----:::::::::::::::-
...----:::::::::/:-`
`.---::/+osss+:`
``.:://///-.
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
const int INF = 2e9;
const int MOD = 1e9 + 7;
i64 lgput(i64 b, i64 e) {
i64 r(1);
while(e) {
if(e & 1) r = (r * b) % MOD;
b = (b * b) % MOD;
e >>= 1;
}
return r;
}
int main() {
#ifdef BLAT
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif // BLAT
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
i64 n, k, ans(0);
cin >> n >> k;
k--;
for(i64 i = 0; (1LL << i) <= k; i++) {
if(k & (1LL << i)) {
ans = ans + lgput(2, n - i - 1);
ans %= MOD;
}
}
ans++;
ans %= MOD;
cout << ans << '\n';
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... |