Submission #832124

#TimeUsernameProblemLanguageResultExecution timeMemory
832124KaleemRazaSyedRack (eJOI19_rack)C++17
100 / 100
8 ms7892 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6+5 , mod = 1e9+7; long long pw[N]; long long f(long long k, int n) { // cerr << "f(" << k << ", " << n << ")\n"; if(n==0) return k; long long l = k/2 + k%2; long long r = k/2; if(l==r) return (pw[n-1]+f(r, n-1))%mod; return f(l, n-1); } int main() { int n; long long k; cin >> n >> k; pw[0] = 1; for(int i=1;i<=n;i++) pw[i] = (pw[i-1]*2)%mod; cout << f(k, n) << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...