Submission #276467

# Submission time Handle Problem Language Result Execution time Memory
276467 2020-08-20T13:04:01 Z FEDIKUS Rack (eJOI19_rack) C++17
40 / 100
1 ms 512 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 inv=powr(2,mod-2);
    while(l<r){
        ll mid=(r+l)/2;
        mid=(mid%mod+mod)%mod;
        l=(l%mod+mod)%mod;
        r=(r%mod+mod)%mod;
        //cout<<l<<" "<<r<<"\n";
        if(k&1){
            r=mid;
            k=(k-1)/2+1;
        }else{
            l=mid+1;
            k/=2;
        }
    }
    cout<<(l+mod)%mod;
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:45:8: warning: unused variable 'inv' [-Wunused-variable]
   45 |     ll inv=powr(2,mod-2);
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Incorrect 0 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -