이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#define int long long
using namespace std;
const long long mod=1e9+7;
long long logExp(long long num, long long e){
if (e == 1) return num;
if (e == 0) return 1;
long long fin = logExp(num, e >> 1) % mod;
fin = (fin * fin) % mod;
if (e & 1) fin = (fin * num) % mod;
return fin;
}
int32_t main()
{
long long n, k;
cin >> n >> k;
long long res = 0;
k--;
for (long long i = n - 1; i >= 0; i--) {
int child = k & 1;
k = k >> 1;
if (child == 1) res = (res + logExp(2, i) % mod ) % mod;
}
cout << (res + 1) % mod;
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... |