Submission #469561

#TimeUsernameProblemLanguageResultExecution timeMemory
469561FatihSolakRack (eJOI19_rack)C++17
40 / 100
1088 ms448 KiB
#include <bits/stdc++.h> #define N 1000005 #define int long long using namespace std; const int mod = 1e9+7; int pw(int b){ int ret = 1; for(int i=0;i<b;i++){ ret = min((int)2e18,ret*2); } return ret; } int pw2(int b){ int ret = 1; for(int i=0;i<b;i++){ ret = ret*2%mod; } return ret; } int get(int n,int k){ if(n == 0)return 1; int ret = 0; if(k > pw(n-1)){ ret = 1; k -= pw(n-1); } return (2*get(n-1,k) -1 +ret+mod)%mod; } void solve(){ int n,k; cin >> n >> k; cout << get(n,k); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...