이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
using namespace std;
const long long mod = 1e9+7;
int binary_exponentiation(int number, int exponent)
{
int result = 1;
while (exponent > 0) {
if(exponent & 1) result = result * number;
number = number * number;
exponent >>= 1;
}
return result;
}
int make_path(long long seed, int length)
{
long long path = 0;
for (int i = 0; i < min(length, 62); i++) {
if (((seed >> i) & 1) == 1) path = (path + binary_exponentiation(2, length - i - 1))%mod;
}
return path;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int height, node;
cin >> height >> node;
cout << (make_path(node - 1, height) + 1)%mod << endl;
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... |