Submission #19341584


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define MAX 9223372036854775807
#define MIN -9223372036854775807
#define PI 3.141592653589
#define setbits(n) __builtin_popcountll(n)
#define mkunique(a) a.resize(unique(a.begin(),a.end())-a.begin());
const ll mod=1e9+7;


 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll T=clock();
 
    ll x,y;
    cin>>x>>y;
    if(x>y){
        cout<<x-y;
        return 0;
    }
    ll ans=0;
    while(x*2<y){
        x*=2;
        ans++;
    }
    ll a=y-x, b=x*2-y;
    ll ca=0, cb=0;
    for(ll i=0;i<=60;i++){
        if((1ll<<i)&a){
            ll k=min(ans,i);
            ca+=(1ll<<i)/(1ll<<k);
        }
    }
    for(ll i=0;i<=60;i++){
        if((1ll<<i)&b){
            ll k=min(ans+1,i);
            cb+=(1ll<<i)/(1ll<<k);
        }
    }
    //cout<<ca<<" "<<cb<<"\n";
    ans=min(ans+ca,ans+1+cb);
    cout<<ans;
    
    
    cerr<<"\n\nTIME: "<<(double)(clock()-T)/CLOCKS_PER_SEC<<" sec\n";
    T = clock();
    return 0;
}

Submission Info

Submission Time
Task F - +1-1x2
User sharath101
Language C++ (GCC 9.2.1)
Score 0
Code Size 1198 Byte
Status WA
Exec Time 8 ms
Memory 3812 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 3
AC × 48
WA × 1
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, extreme_04.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_03.txt, handmade_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_exp_00.txt, random_exp_01.txt, random_exp_02.txt, random_exp_03.txt, random_exp_04.txt, random_exp_05.txt, random_exp_06.txt, random_exp_07.txt, random_exp_08.txt, random_exp_09.txt, random_exp_10.txt, random_exp_11.txt, random_exp_12.txt, random_exp_13.txt, random_exp_14.txt, random_exp_15.txt, random_small_00.txt, random_small_01.txt, random_small_02.txt, random_small_03.txt, random_small_04.txt, random_small_05.txt, random_small_06.txt, random_small_07.txt, random_small_08.txt, random_small_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 8 ms 3700 KB
extreme_01.txt AC 2 ms 3696 KB
extreme_02.txt AC 2 ms 3656 KB
extreme_03.txt AC 2 ms 3664 KB
extreme_04.txt AC 2 ms 3812 KB
handmade_00.txt AC 3 ms 3664 KB
handmade_01.txt AC 2 ms 3648 KB
handmade_02.txt AC 2 ms 3484 KB
handmade_03.txt WA 3 ms 3668 KB
handmade_04.txt AC 2 ms 3568 KB
random_00.txt AC 2 ms 3584 KB
random_01.txt AC 2 ms 3796 KB
random_02.txt AC 2 ms 3620 KB
random_03.txt AC 2 ms 3540 KB
random_04.txt AC 2 ms 3620 KB
random_05.txt AC 1 ms 3700 KB
random_06.txt AC 2 ms 3564 KB
random_07.txt AC 2 ms 3752 KB
random_08.txt AC 2 ms 3620 KB
random_09.txt AC 2 ms 3620 KB
random_exp_00.txt AC 2 ms 3624 KB
random_exp_01.txt AC 2 ms 3540 KB
random_exp_02.txt AC 1 ms 3740 KB
random_exp_03.txt AC 2 ms 3540 KB
random_exp_04.txt AC 2 ms 3740 KB
random_exp_05.txt AC 2 ms 3516 KB
random_exp_06.txt AC 2 ms 3536 KB
random_exp_07.txt AC 2 ms 3736 KB
random_exp_08.txt AC 1 ms 3640 KB
random_exp_09.txt AC 2 ms 3660 KB
random_exp_10.txt AC 2 ms 3528 KB
random_exp_11.txt AC 2 ms 3488 KB
random_exp_12.txt AC 2 ms 3620 KB
random_exp_13.txt AC 4 ms 3540 KB
random_exp_14.txt AC 2 ms 3656 KB
random_exp_15.txt AC 2 ms 3540 KB
random_small_00.txt AC 2 ms 3800 KB
random_small_01.txt AC 3 ms 3712 KB
random_small_02.txt AC 2 ms 3700 KB
random_small_03.txt AC 2 ms 3516 KB
random_small_04.txt AC 2 ms 3472 KB
random_small_05.txt AC 2 ms 3612 KB
random_small_06.txt AC 2 ms 3740 KB
random_small_07.txt AC 2 ms 3736 KB
random_small_08.txt AC 2 ms 3520 KB
random_small_09.txt AC 2 ms 3712 KB
sample_01.txt AC 2 ms 3740 KB
sample_02.txt AC 2 ms 3732 KB
sample_03.txt AC 2 ms 3656 KB