# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
840856 | raul2008487 | Rack (eJOI19_rack) | C++17 | 8 ms | 7928 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define vl vector<ll>
#define endl "\n"
#define all(v) v.begin(), v.end()
using namespace std;
const int sz = 2e6+5;
const ll inf = 100000000000000005;
const int mod = 1e9+7;
ll tp[sz];
ll rec(ll k, ll n){
if(n==0){
return k;
}
ll lc = k/2 + k%2;
ll rc = k/2;
if(lc == rc){
return (tp[n-1] + rec(rc, n-1))%mod;
}
return rec(lc,n-1);
}
void solve(){
ll n,k,i,j;
cin>>n>>k;
tp[0] = 1;
for(i=1;i<=n;i++){
tp[i] = tp[i-1] * 2;
tp[i] %= mod;
}
cout << rec(k, n) << endl;
}
int main(){
ll t=1;
//cin>>t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |