Submission #884737

#TimeUsernameProblemLanguageResultExecution timeMemory
884737Perl32Rack (eJOI19_rack)C++14
100 / 100
2 ms348 KiB
/** * author: Perl32 * created: 18.11.2023 09:12:21 **/ #ifdef LOCAL # define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #define ff first #define ss second #define szof(x) (int) x.size() #define all(x) x.begin(), x.end() #ifndef LOCAL # define cerr if (0) cerr #endif using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; using pii = pair<int, int>; using ull = unsigned long long; template<typename T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int INF = (int) 1e9 + 1e3; const ll INFL = (ll) 1e18 + 1e9; #ifdef LOCAL mt19937 tw(9450189); #else mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count()); #endif uniform_int_distribution<ll> ll_distr; ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; } const ll MOD = (ll) 1e9 + 7; ll binpow(ll a, ll n) { ll ret = 1; while (n) { if (n & 1) { ret = (ret * a) % MOD; --n; } a = (a * a) % MOD; n >>= 1; } return ret; } signed main() { #ifdef LOCAL freopen("inp.txt", "r", stdin); freopen("out.txt", "w", stdout); freopen("err.txt", "w", stderr); auto start_time = clock(); cerr << setprecision(3) << fixed; #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n, k; cin >> n >> k; ll ans = 1; for (ll i = n - 1; i >= 0; --i) { if (k & 1) { k++; } else { ans = (ans + binpow(2, i)) % MOD; } k = (k + 1) / 2; } cout << ans; #ifdef LOCAL auto end_time = clock(); cerr << "Execution time: " << (end_time - start_time) * (ll) 1e3 / CLOCKS_PER_SEC << " ms\n"; #endif } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...