Submission #791608

#TimeUsernameProblemLanguageResultExecution timeMemory
791608otariusRack (eJOI19_rack)C++17
100 / 100
7 ms4556 KiB
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <queue> #include <map> #include <cmath> #include <iomanip> using namespace std; #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair <int, int> #define ull unsigned long long // #define int long long // #define int unsigned long long const ll inf = 1e9 + 7; const ll weirdMod = 998244353; ll ans = 0, cur = 1; void solve() { ll n, k; cin >> n >> k; k--; vector<int> bin; while (k) { bin.pb(k % 2); k /= 2; } while (bin.size() < n) bin.pb(0); for (int i = n - 1; i >= 0; i--) { if (bin[i] == 1) (ans += cur) %= inf; (cur *= 2) %= inf; } cout << (ans + 1) % inf; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }

Compilation message (stderr)

rack.cpp: In function 'void solve()':
rack.cpp:34:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |     } while (bin.size() < n) bin.pb(0);
      |              ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...