Submission #724949

#TimeUsernameProblemLanguageResultExecution timeMemory
724949MercubytheFirstRack (eJOI19_rack)C++14
40 / 100
1 ms212 KiB
#include<bits/stdc++.h>
#define int uint64_t
using namespace std;
const int mod = 1e9 + 7;

int cdiv(int a, int b){
    return (a + b - 1ll) / b;
}

int bpow(int a, int b){
    if(a == 1 or b == 0)return 1;
    if(a == 0)return 0; // watch out for 0^0
    int ans = 1;
    a %= mod;
    while(b > 0){
        if(b&1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
} 


signed main(){
    int n, k;
    cin >> n >> k;
    n--;
    int ans = 1, add = bpow(2,n);
    while(k > 1){
        if(!(k&1))ans += add % mod;
        n--;
        add = bpow(2,n);
        k = cdiv(k,2);
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...