Submission #894415

# Submission time Handle Problem Language Result Execution time Memory
894415 2023-12-28T09:05:35 Z vjudge1 Rack (eJOI19_rack) C++17
40 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ppb pop_back()

const int N = (int)1e5 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (1e9) + 100;

ll binpow(ll a, ll n) {
    if (n == 0) return 1;
    if (n == 1) return a % mod;
    int v = binpow(a, n / 2);
    if (n & 1) return (((v * v) % mod) * a) % mod;
    return (v * v) % mod;
}

ll add(ll a, ll b) {
    return (((a + b) % mod) + mod) % mod;
}

void solve() {
    ll n, k;
    cin >> n >> k;
    ll ans = 1;
    ll p = binpow(2, n - 1);
    ll l = n - 1;
    while (k > 1) {
        if (k & 1) {
            k = (k / 2) + 1;
        } else {
            k /= 2;
            ans = add(ans, p);
        }
        l--;
        l = max(0LL, l);
        p = binpow(2, l);
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Incorrect 0 ms 344 KB Output isn't correct
12 Halted 0 ms 0 KB -