Submission #791605

#TimeUsernameProblemLanguageResultExecution timeMemory
791605otariusRack (eJOI19_rack)C++17
40 / 100
1 ms212 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() { int 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 '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...