Submission #448537

# Submission time Handle Problem Language Result Execution time Memory
448537 2021-07-30T13:09:38 Z Tenis0206 Rack (eJOI19_rack) C++11
100 / 100
1 ms 312 KB
#include <bits/stdc++.h>

using namespace std;
const int Mod = 1e9+7;
long long lgput(int b, int e)
{
    long long p=1;
    while(e)
    {
        if(e%2==1)
        {
            e--;
            p=(1LL*p*b)%Mod;
        }
        else
        {
            e/=2;
            b=(1LL*b*b)%Mod;
        }
    }
    return p;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n,k;
    cin>>n>>k;
    long long rez=1;
    while(k!=1)
    {
        --n;
        if(k%2==0)
        {
            rez+=lgput(2,n);
            rez%=Mod;
        }
        k=(k+1)/2;
    }
    cout<<rez<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 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 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 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 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 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 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 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 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct