Submission #763708

#TimeUsernameProblemLanguageResultExecution timeMemory
763708ivopavRack (eJOI19_rack)C++14
40 / 100
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; int k; cin >> n >> k; k--; vector<bool> bin={}; while (k>0){ bin.push_back(k%2); k/=2; } while (bin.size()<n){ bin.push_back(0); } int rje=0; reverse(bin.begin(),bin.end()); int sad=1; for (int i=0;i<bin.size();i++){ if (bin[i]){ rje+=sad; } sad*=2; } cout << rje+1 << "\n"; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:14:22: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |     while (bin.size()<n){
      |            ~~~~~~~~~~^~
rack.cpp:20:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i=0;i<bin.size();i++){
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...