답안 #763761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763761 2023-06-22T20:15:35 Z NemanjaSo2005 Rack (eJOI19_rack) C++17
100 / 100
11 ms 2328 KB
#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

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)
      |          ~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 11 ms 2328 KB Output is correct