제출 #634276

#제출 시각아이디문제언어결과실행 시간메모리
634276antimirageRack (eJOI19_rack)C++14
100 / 100
10 ms8120 KiB
#include <bits/stdc++.h>

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 <= (1LL << j)) {
            if (j > 0) 
                ans = (ans + two[pw]) % mod;
            else {
                cout << (ans + 1) % mod << endl;
                return 0;
            }
            k -= (1LL << (j - 1));
            pw = n;
            j = -1;
        } else {
            pw--;
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

rack.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...