Submission #894419

# Submission time Handle Problem Language Result Execution time Memory
894419 2023-12-28T09:07:46 Z vjudge1 Cipele (COCI18_cipele) C++17
0 / 90
1 ms 512 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 0;
    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--;
        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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -