Submission #638465

#TimeUsernameProblemLanguageResultExecution timeMemory
638465ShirleyMRack (eJOI19_rack)C++14
40 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; typedef vector<bool> vb; typedef vector<vb> vvb; #define x first #define y second #define pb push_back #define loop(i,s,e) for(int i=s;i<e;i++) #define loopr(i,s,e) for(int i=e-1;i>=s;i--) #define chkmax(a,b) a=max(a,b) #define chkmin(a,b) a=min(a,b) #define all(a) a.begin(),a.end() #define fast {ios_base::sync_with_stdio(false); cin.tie(0);} const int inf = 1e18; const int INF = 1e9; const int mod = 1e9+7; int32_t main() { fast; int n; int k; cin >> n >> k; vi mul(n+1, 1); loop(i,1,n+1) mul[i] = (mul[i-1] * 2)%mod; int ind = k; ind--; int ans = 1; while(ind!=0){ int i = log2(ind); (ans += mul[n-i-1]); ind -= mul[i]; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...