이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1e6 + 60;
ll n, k;
ll a[N];
int main()
{
a[0] = 1LL;
for(int i = 1;i<N;i++) a[i] = (a[i-1]*2LL)%mod;
ios
cin>>n>>k;
ll stepen = 2LL;
ll ind = n-1LL;
ll l = 1LL;
int par = 0;
while(true)
{
if(k%stepen==0)
{
l = (l+a[ind])%mod;
}
else
{
if(par==0) ind--;
par = 1;
ll aa = k % (stepen/2LL);
ll b = aa + stepen/2LL;
if(k%stepen==b)
{
l = (l+a[ind])%mod;
}
}
if(stepen>=k) break;
ind--;
stepen*=2LL;
}
cout<<l;
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... |