제출 #284084

#제출 시각아이디문제언어결과실행 시간메모리
284084Patrusheva_AnnaRack (eJOI19_rack)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("O3") #define ll long long #define pb push_back #define F first #define S second #define ull unsigned long long #define pii pair < int, int > #define ld long double using namespace std; using namespace __gnu_pbds; mt19937 gen(time(0)); template <typename T> using ordered_set=tree<T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 100000 * 5; int n; void Solve(int k) { vector < ll > p; for (int i = n - 1; i >= 1; i--) p.pb((1ll << i)); ll ans = 1; for (int i = 0; i < min(60, (int)p.size()); i++) { ll kol = k / (1ll << i); ll ost = k % (1ll << i); if (kol % 2 == 1 && ost > 0) ans = (ans + p[i]) % 1000000007; else if (kol % 2 == 0 && ost == 0) ans = (p[i] + ans) % 1000000007; } cout << ans<< "\n"; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #else #endif cin >> n; ll k; cin >> k; Solve(k); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...