답안 #448790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448790 2021-08-01T13:35:46 Z UltraFalcon Rack (eJOI19_rack) C++17
100 / 100
117 ms 316 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

int pow_mod(int b, int p, int m) {
    int r = 1;
    for (int i=0; i<p; i++) {
        r = (r*b) % m;
    }
    return r;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    const int limit = (1e9) + 7;

    int n, k;
    cin >> n >> k;

    k--;
    int i = n-1;
    int r = 1;

    while (i >= 0) {
        if (k % 2 == 1) {
            //assert(i < 62);
            r = (r + pow_mod(2, i, limit)) % limit;
        }
        k /= 2;
        i--;
    }
    cout << r % limit << "\n";
}
# 결과 실행 시간 메모리 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 1 ms 204 KB Output is correct
5 Correct 0 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 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 308 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 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 308 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 1 ms 204 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 9 ms 204 KB Output is correct
15 Correct 117 ms 204 KB Output is correct