답안 #735126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735126 2023-05-03T15:06:51 Z makrav Rack (eJOI19_rack) C++14
100 / 100
1 ms 320 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vei;
typedef vector<vei> vevei;

#define coa               \
            for (auto i : a) {    \
                cout << i << ' '; \
            }                     \
            cout << '\n';
#define cia             \
            for (auto& i : a) { \
                cin >> a;       \
            }
#define cna                       \
            int n;                        \
            cin >> n;                     \
            vector<int> a(n);             \
            for (int i = 0; i < n; i++) { \
                cin >> a[i];              \
            }
#define cnka                      \
            int n, k;                     \
            cin >> n >> k;                \
            vector<int> a(n);             \
            for (int i = 0; i < n; i++) { \
                cin >> a[i];              \
            }
#define cnab                      \
            int n;                        \
            cin >> n;                     \
            vector<int> a(n);             \
            for (int i = 0; i < n; i++) { \
                cin >> a[i];              \
            }                             \
            vector<int> b(n);             \
            for (int i = 0; i < n; i++) { \
                cin >> b[i];              \
            }
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) a.size()
#define con cout << "NO\n"
#define coe cout << "YES\n";
#define str string
#define pb push_back
#define ff first
#define sc second
#define pii pair<int, int>
#define mxe max_element
#define mne min_element
#define stf shrink_to_fit
#define f(i, l, r) for (int i = (l); i < (r); i++)
#define double ld
#define int long long

const int mod = 1e9 + 7;
int binpow(int a, int p) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int b = binpow(a, p / 2);
        return (b * b) % mod;
    }
    return (a * binpow(a, p - 1)) % mod;
}

int get(int n, int k) {
    if (k == 1) return 1;
    if (k % 2 == 0) {
        return (binpow(2, n - 1) + get(n - 1, k / 2)) % mod;
    }
    else {
        return get(n - 1, (k + 1) / 2);
    }
}

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

    int n, k; cin >> n >> k;
    cout << get(n, k) << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct