Submission #433189

#TimeUsernameProblemLanguageResultExecution timeMemory
433189Valaki2Rack (eJOI19_rack)C++14
100 / 100
13 ms8064 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9+7; void solve() { ll n, k; cin >> n >> k; --k; vector<ll> powers_of_2_nomodulo(61, 0); vector<ll> powers_of_2(1 + n, 0); powers_of_2[0] = 1; powers_of_2_nomodulo[0] = 1; for(ll i = 1; i <= n; ++i) { powers_of_2[i] = (powers_of_2[i - 1] * 2) % mod; } for(ll i = 1; i <= 60; ++i) { powers_of_2_nomodulo[i] = powers_of_2_nomodulo[i - 1] * 2; } vector<bool> bits_of_k(1 + n, false); ll max_bit_of_k = 0; for(ll i = 0; i <= 60; ++i) { if(k & powers_of_2_nomodulo[i]) { bits_of_k[i] = true; max_bit_of_k = i; } } ll to_add = n - 1; ll where_we_are = 0; ll answer = 1; while(to_add >= 0) { if(bits_of_k[where_we_are]) { answer = (answer + powers_of_2[to_add]) % mod; } ++where_we_are; --to_add; } cout << answer << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }

Compilation message (stderr)

rack.cpp: In function 'void solve()':
rack.cpp:23:8: warning: variable 'max_bit_of_k' set but not used [-Wunused-but-set-variable]
   23 |     ll max_bit_of_k = 0;
      |        ^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...