제출 #577193

#제출 시각아이디문제언어결과실행 시간메모리
577193berrRack (eJOI19_rack)C++17
100 / 100
4 ms324 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...