제출 #639123

#제출 시각아이디문제언어결과실행 시간메모리
639123irmuunRack (eJOI19_rack)C++17
100 / 100
3 ms340 KiB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pi pair<ll,ll>
#define PI 3.1415926535897932384626433

const ll mod=1000000007,mod1=998244353,INF=1e18,MAX=1e9;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    auto fastPow=[&](ll a,ll b) {
        ll res=1;
        while(b>0){
            if(b%2==1){
                res*=a;
                res%=mod;
            }
            b/=2;
            a=a*a%mod;
        }
        return res;
    };
    ll v=1;
    ll ans=1;
    while(v!=n+1){
        if(k%2==0){
            ans+=fastPow(2,n-v);
            ans%=mod;
        }
        k=k/2+k%2;
        v++;
    }
    cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...