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