Submission #438408

#TimeUsernameProblemLanguageResultExecution timeMemory
438408NintsiChkhaidzeRack (eJOI19_rack)C++14
40 / 100
1 ms204 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
#define s second
#define f first
#define pii pair<int,int>
#define mod 1000000007
 
using namespace std;
const int N = 1000005;
ll pwr[N];
 
int main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    
    int n,k;
    cin>>n>>k;
    
    pwr[0] = 1;
    for (int i = 1; i <= n; i++)
        pwr[i] = (pwr[i - 1]*(ll)2)%mod;
        
    ll ans = 1;
    while (n){
        if (!(k%2)) ans = (pwr[n - 1] + ans)%mod;
        n--;
        k = (k + 1)/2;
    }
    
    cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...