/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 2ms 536.0 KiB
#4 Accepted 236ms 792.0 KiB
#5 Accepted 231ms 668.0 KiB

Code

#include  <bits/stdc++.h>
using namespace std;
 
#ifdef LOCAL
#include "debug.hpp"
#else
#define bug(...)
#endif

typedef long long ll;
#define endl "\n"
#define ws " "
#define yy cout<<"YES\n";
#define nn cout<<"NO\n";

signed main(){
    int tc=0, tcMax=1;
    cin >> tcMax;
    while (tc++<tcMax) {
        // bug(tc);
        int a,b;
        cin>>a>>b;
        int count = 0;
        while(1){
            if(b%2){
                // bug(b);
                count++;
            }
            b/=2;
            if(b<a){
                // bug(b);
                b*=2;
                count+=b-a;
                // bug(count);
                break;
            }else{
                // bug(a,b);
                count++;
                // bug(count);
            }
            // bug(b);
        }
        cout<<count<<endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1044 Add or multiple
Contest
TLE_Headquarters - round #1
Language
C++17 (G++ 13.2.0)
Submit At
2024-03-27 17:43:44
Judged At
2024-11-11 03:37:28
Judged By
Score
100
Total Time
236ms
Peak Memory
792.0 KiB