Submission #763761

#TimeUsernameProblemLanguageResultExecution timeMemory
763761NemanjaSo2005Rack (eJOI19_rack)C++17
100 / 100
11 ms2328 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll N,K,MOD=1e9+7; string ubin(ll x){ string ret; while(x){ ret.push_back(x%2); x/=2; } return ret; } ll udec(string a){ ll st=1,ret=0; for(int i=a.size()-1;i>=0;i--){ ret=(ret+a[i]*st)%MOD; st=(st*2)%MOD; } return ret; } int main(){ cin>>N>>K; string a=ubin(K-1); while(a.size()<N) a.push_back(0); cout<<udec(a)+1<<endl; return 0; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:24:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   24 |    while(a.size()<N)
      |          ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...