This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod=1e9+7;
int poww(int a, int b)
{
if(b==0) return 1;
int tmp=poww(a, b/2);
if(b%2==0) return (tmp*tmp)%mod;
else return (((tmp*tmp)%mod)*a)%mod;
}
int sum(int a, int b)
{
return ((((a+b)%mod)+mod)%mod);
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, k; cin>>n>>k;
n--;
int ans=1;
while(n>=0)
{
if(k%2==0) ans=sum(ans, poww(2, n)), k/=2;
else k++, k/=2;
n--;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |