# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1213015 | vincentbucourt1 | Rack (eJOI19_rack) | C11 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
int N, numIter;
int ans = 1;
long long modular(long long base, long long exp, int mod) {
long long res = 1;
while (exp > 0) {
if (exp % 2 == 1)
res= (res * base) % mod;
exp = exp >> 1;
base = (base * base) % mod;
}
return res;
}
signed main() {
cin >> N >> numIter;
numIter--;
for (int i = 0; i <= 63; i++) {
bool filled = (numIter & (1 << i));
if (N - i - 1 >= 0) {
ans += (modular(2, N - i - 1, MOD)) * filled;
ans %= MOD;
}
}
cout << ans << "\n";
}