Submission #587360

#TimeUsernameProblemLanguageResultExecution timeMemory
587360Markomafko972Rack (eJOI19_rack)C++14
100 / 100
17 ms8948 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll Mod = 1e9 + 7; int n; ll k; string s; ll pot[1000007]; ll m(ll x) { return (x < Mod) ? x : x % Mod; } int main () { cin >> n >> k; for (int i = 0; i < n; i++) { if (k & 1) { s += '0'; } else { s += '1'; } k = (k + 1) / 2; } int y = s.size(); pot[y-1] = 1; for (int i = y-2; i >= 0; i--) { pot[i] = m(pot[i+1] * 2); } ll res = 0; for (int i = 0; i < y; i++) { res = m(res + (s[i] - '0') * pot[i]); } cout << res+1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...