Submission #448354

# Submission time Handle Problem Language Result Execution time Memory
448354 2021-07-29T19:27:23 Z mychecksedad Rack (eJOI19_rack) C++17
100 / 100
8 ms 316 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD (1000000000+7)

ll fp(ll a, ll b){
    ll res = 1;
    while(b){
        if(b&1) (res*=a)%=MOD;
        (a*=a)%=MOD;
        b>>=1;
    }
    return res;
}


int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    ll n, k, ans=1;
    cin >> n >> k;
    for(ll i = n-1; i >= 0; i--){
        if(k&1){
            k = (k>>1) + 1;
        }else{
            k >>= 1;
            ans += fp(2, i);
        }
        (ans%=MOD);
        (ans+=MOD)%=MOD;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 8 ms 204 KB Output is correct