Submission #893840

#TimeUsernameProblemLanguageResultExecution timeMemory
893840Essa2006Rack (eJOI19_rack)C++14
100 / 100
12 ms4188 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int add(ll a, ll b) { ll res = a + b; return res % mod; } int mul(ll a, ll b) { a %= mod, b %= mod; ll res = a * b; return res % mod; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n, k; cin >> n >> k; vector<int> Pwr_of_two(n+1); Pwr_of_two.front() = 1; for (int i = 1; i <= n; i++) { Pwr_of_two[i] = mul(Pwr_of_two[i - 1], 2); } ll ans = 1; for (int i = n - 1; i >= 0; i--) { if (k % 2 == 0) { ans = add(ans, Pwr_of_two[i]); } k = (k + 1) / 2; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...