이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9+7;
ll power(int x, int y)
{
ll temp;
if(y == 0)
return 1;
temp = power(x, y / 2);
if (y % 2 == 0)
return (temp * temp) % mod;
else {
if(y > 0)
return (x * temp * temp)%mod;
else
return ((temp * temp) / x) % mod;
}
}
int main()
{
ll n, k;
cin >> n >> k;
if(k == 1) {
cout << 1;
return 0;
}
ll ans = 1;
for(int i = n-1; i >= 0; i--) {
if(k % 2 == 1) {
k = k / 2 + 1;
}
else {
k /= 2;
ans += power(2, i);
ans %= mod;
}
}
cout << ans;
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... |