이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// author: erray
#include<bits/stdc++.h>
using namespace std;
const int mod = (int) 1e9 + 7;
long long power(long long b, long long p) {
long long res = 1;
while (p) {
if (p & 1) (res *= b) %= mod;
(b *= b) %= mod;
p >>= 1;
}
return res;
}
vector<long long> fac(1, 1), inv_fac(1, 1);
long long C(int x, int y) {
if (x < y) return 0;
while ((int) fac.size() <= x) {
fac.push_back((fac.back() * (int) fac.size()) % mod);
inv_fac.push_back(power(fac.back(), mod - 2));
}
return fac[x] * inv_fac[y] % mod * inv_fac[x - y] % mod;
}
long long P(int x, int y) {
if (x < y) return 0;
while ((int) fac.size() <= x) {
fac.push_back((fac.back() * (int) fac.size()) % mod);
inv_fac.push_back(power(fac.back(), mod - 2));
}
return fac[x] * inv_fac[y] % mod;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long long k;
cin >> n >> k;
--k;
long long ans = 1;
for (int i = 0; i < 64; ++i) {
if (k & (1LL << i)) {
(ans += power(2, n - 1 - i)) %= mod;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |