Submission #276503

# Submission time Handle Problem Language Result Execution time Memory
276503 2020-08-20T13:17:54 Z FEDIKUS Rack (eJOI19_rack) C++17
100 / 100
176 ms 384 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,ll) sort(a.begin(),a.end(),greater<ll>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define up(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;
typedef string str;

const ll mod=1e9+7;

ll powr(ll a,ll b){
    if(b==0) return 1;
    ll ret=powr(a,b/2);
    ret*=ret;
    ret%=mod;
    if(b&1) ret*=a;
    ret%=mod;
    return ret;
}

int main()
{
    ios;
    ll n,k;
    cin>>n>>k;
    ll l=1;
    ll r=powr(2,n);
    ll vel=n;
    while(vel){
        ll mid=l+powr(2,vel-1)-1;
        mid=(mid%mod+mod)%mod;
        //cout<<l<<" "<<r<<" "<<k<<"\n";
        if(k&1){
            r=mid;
            k=(k-1)/2+1;
        }else{
            l=mid+1;
            l%=mod;
            k/=2;
        }
        vel--;
    }
    cout<<(l%mod+mod)%mod;
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:44:8: warning: variable 'r' set but not used [-Wunused-but-set-variable]
   44 |     ll r=powr(2,n);
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 9 ms 384 KB Output is correct
15 Correct 176 ms 384 KB Output is correct