답안 #634276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634276 2022-08-24T08:22:30 Z antimirage Rack (eJOI19_rack) C++14
100 / 100
10 ms 8120 KB
#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--;
        }
    }
}

Compilation message

rack.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 8 ms 8020 KB Output is correct
3 Correct 9 ms 8060 KB Output is correct
4 Correct 8 ms 8120 KB Output is correct
5 Correct 10 ms 8088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 8 ms 8020 KB Output is correct
3 Correct 9 ms 8060 KB Output is correct
4 Correct 8 ms 8120 KB Output is correct
5 Correct 10 ms 8088 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 8 ms 8068 KB Output is correct
8 Correct 9 ms 8056 KB Output is correct
9 Correct 8 ms 8112 KB Output is correct
10 Correct 8 ms 8020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 8 ms 8020 KB Output is correct
3 Correct 9 ms 8060 KB Output is correct
4 Correct 8 ms 8120 KB Output is correct
5 Correct 10 ms 8088 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 8 ms 8068 KB Output is correct
8 Correct 9 ms 8056 KB Output is correct
9 Correct 8 ms 8112 KB Output is correct
10 Correct 8 ms 8020 KB Output is correct
11 Correct 8 ms 8020 KB Output is correct
12 Correct 8 ms 8020 KB Output is correct
13 Correct 8 ms 8112 KB Output is correct
14 Correct 8 ms 8116 KB Output is correct
15 Correct 9 ms 8116 KB Output is correct