이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
#define int long long
const int N = (1<<20) + 1;
int tp[N];
int mod = 1e9 + 7;
void solve(int n,int k){
bool right = true;
int ans = 0;
for (int i=1;i<=n;i++){
bool last = 1&k;
k >>= 1;
if (right and last)
right = 0;
else if (right)
ans += tp[n - i];
else if (!right and last)
ans += tp[n - i];
}
cout<<(ans + !right)%mod<<endl;
}
signed main(){
tp[0] = 1;
for (int i=1;i<N;i++)
tp[i] = tp[i-1] * 2 % mod;
int n,k;
cin>>n>>k;
if (k==tp[n])
cout<<tp[n]<<endl;
else
solve(n,k);
return 0;
for (int i=1;i<=8;i++)
solve(3,i);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |