Submission #970575

# Submission time Handle Problem Language Result Execution time Memory
970575 2024-04-26T17:51:40 Z Ludissey Rack (eJOI19_rack) C++14
100 / 100
1 ms 600 KB
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
using namespace std;

const int mod=1e9+7;
int MOD(int x){
    return ((x+mod)%mod);
}

int fast_pow(int x, int p){
    if(p==1) return x;
    if(p==0) return 1;
    if(p%2==0) return MOD(MOD(fast_pow(x,p/2))*MOD(fast_pow(x,p/2)));
    else return MOD(MOD(fast_pow(x,p-1))*x);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n,k; cin >> n>>k;
    k--;
    int sum=1;
    for (int i = 1; i <= n; i++)
    {
        if((1LL<<(i-1LL))>k) break;
        if(k&(1LL<<(i-1LL))) sum=MOD(sum+MOD(fast_pow(2LL, (n-i))));
    }
    cout << sum << "\n";
    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 600 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 600 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 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 600 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 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 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct