Submission #369968

# Submission time Handle Problem Language Result Execution time Memory
369968 2021-02-22T20:16:43 Z iliccmarko Rack (eJOI19_rack) C++14
100 / 100
19 ms 8172 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define single_case solve();
#define line cerr<<"----------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL); }
#define mod 1000000007LL
const int N = 1e6 + 60;
ll n, k;
ll a[N];


int main()
{
    a[0] = 1LL;
    for(int i = 1;i<N;i++) a[i] = (a[i-1]*2LL)%mod;
    ios
    cin>>n>>k;
    ll stepen = 2LL;
    ll ind = n-1LL;
    ll l = 1LL;
    int par = 0;
    while(k%stepen==0)
    {
        l = (l+a[ind])%mod;
        if(k%(stepen*2LL)!=0){
            ind--;
            stepen*=2LL;
            break;
        }
        ind--;
        stepen*=2LL;
    }
    ind--;
    stepen*=2LL;
    while(true)
    {
        //cout<<ind<<endl;
        ll aa = k%(stepen/2LL);
        ll b = aa + stepen/2LL;
        if(k%stepen==b) l = (l+a[ind])%mod;
        ind--;
        if(stepen>k) break;
        stepen*=2LL;
    }

    cout<<l;





    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:29:9: warning: unused variable 'par' [-Wunused-variable]
   29 |     int par = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 12 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 12 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
6 Correct 8 ms 8172 KB Output is correct
7 Correct 8 ms 8172 KB Output is correct
8 Correct 9 ms 8172 KB Output is correct
9 Correct 9 ms 8172 KB Output is correct
10 Correct 8 ms 8172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8172 KB Output is correct
2 Correct 9 ms 8172 KB Output is correct
3 Correct 9 ms 8172 KB Output is correct
4 Correct 12 ms 8172 KB Output is correct
5 Correct 9 ms 8172 KB Output is correct
6 Correct 8 ms 8172 KB Output is correct
7 Correct 8 ms 8172 KB Output is correct
8 Correct 9 ms 8172 KB Output is correct
9 Correct 9 ms 8172 KB Output is correct
10 Correct 8 ms 8172 KB Output is correct
11 Correct 9 ms 8172 KB Output is correct
12 Correct 13 ms 8172 KB Output is correct
13 Correct 10 ms 8172 KB Output is correct
14 Correct 19 ms 8172 KB Output is correct
15 Correct 8 ms 8172 KB Output is correct