Submission #634272

# Submission time Handle Problem Language Result Execution time Memory
634272 2022-08-24T08:20:33 Z antimirage Rack (eJOI19_rack) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>

using namespace std;

const int N = 1e6 + 5;

long long n, k, ans, mod = 1e9 + 7, two[N];

main(){
    cin >> n >> k;
    
    two[0] = 1;
    for (int i = 1; i < N; i++) {
        two[i] = two[i - 1] * 2 % mod;
    }
    
    long long pw = n;
    for (long long j = 0; j <= n; j++) {
        assert(j > 60);
        if (k <= (1 << j)) {
            if (j > 0) 
                ans = (ans + two[pw]) % mod;
            else {
                cout << (ans + 1) % mod << endl;
                return 0;
            }
            k -= (1 << (j - 1));
            pw = n;
            j = -1;
        } else {
            pw--;
        }
    }
}

Compilation message

rack.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
rack.cpp: In function 'int main()':
rack.cpp:24:9: error: 'assert' was not declared in this scope
   24 |         assert(j > 60);
      |         ^~~~~~
rack.cpp:7:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    6 | #include <map>
  +++ |+#include <cassert>
    7 |