제출 #1334222

#제출 시각아이디문제언어결과실행 시간메모리
1334222tsengangRack (eJOI19_rack)C++20
100 / 100
8 ms11332 KiB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ertunt return
using namespace std;
ll mod = 1e9+7;
vector<ll> adj[600007];
vector<ll>vis(200005);
vector<ll> f(600005), inv(600005);
ll modpow(ll a, ll b){
    ll r = 1;
    while(b){
        if(b & 1){
            r *= a;
            r %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    ertunt r;
}
ll nCk(ll n, ll k){
    if(k < 0 || k > n) ertunt 0;
    ertunt f[n] * inv[k] % mod * inv[n - k] % mod;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;	
	cin >> n >> k;
	ll ans = 1;
	ll r = n;
	ll l = 0;
	ll cur = 0;
	while(k > 1){
		cur++;
		if(k%2){
			r--;
		}
		else{
			l++;
			ans+=modpow(2,n-cur);
			ans%=mod;
		}
		k = (k+1)/2;
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...