/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 524.0 KiB
#2 Time Exceeded ≥2095ms ≥436.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 33ms 660.0 KiB
#5 Time Exceeded ≥2093ms ≥764.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define ld long double
#define endl '\n'
#define fasterio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

void solve() {
    // Your code here
    ll a,b;
    cin>>a>>b;
    ll count=0;
    while (a!=b)
    {
        if(b%2==0){
            b/=2;
            count++;
        }else{
            b--;
            count++;
        }
    }
    cout<<count<<endl;
    
}

int main() {
    fasterio;
    // Always use ll, int may give TLE
    ll t;
    cin >> t;
    // t=1;
    while (t--) {
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1044 Add or multiple
Contest
TLE_Headquarters - round #1
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-27 16:49:43
Judged At
2024-11-11 03:38:00
Judged By
Score
60
Total Time
≥2095ms
Peak Memory
≥764.0 KiB