답안 #467887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467887 2021-08-25T13:07:04 Z alontanay Rack (eJOI19_rack) C++14
100 / 100
5 ms 308 KB
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll square(ll n) {
    return n*n;
}

ll pow2(ll n) {
    if(n == 0) { return 1; }
    return ((n%2)+1)*square(pow2(n/2));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;
    ll curr_pow = 1, total = 0;
    for( ; n > 60; n --) {
        curr_pow = (curr_pow*2)%MOD;
    }
    for(ll i = pow2(n-1); i > 0; i >>= 1) {
        if(i < k) {
            total = (total + curr_pow)%MOD;
            k -= i;
        }
        curr_pow = (curr_pow*2)%MOD;
    }
    cout << (total+1)%MOD << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 5 ms 204 KB Output is correct