Submission #577193

# Submission time Handle Problem Language Result Execution time Memory
577193 2022-06-14T08:59:07 Z berr Rack (eJOI19_rack) C++17
100 / 100
4 ms 324 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod=1e9+7;

int poww(int a, int b)
{
    if(b==0) return 1;
    
    int tmp=poww(a, b/2);

    if(b%2==0) return (tmp*tmp)%mod;
    else return (((tmp*tmp)%mod)*a)%mod;
}


int sum(int a, int b)
{
    return ((((a+b)%mod)+mod)%mod);
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n, k; cin>>n>>k;

    n--;
    int ans=1;
    while(n>=0)
    {
        if(k%2==0) ans=sum(ans, poww(2, n)), k/=2;
        else k++, k/=2;
        n--;
    }

    cout<<ans;   

  

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 4 ms 212 KB Output is correct