/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 536.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 32ms 784.0 KiB
#5 Wrong Answer 32ms 816.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;
    
// }
void solve() {
    ll a,b;
    cin>>a>>b;
    ll count=0;
    while (b>a) {
        if(b%2==0) {
            b/=2;
        }else{
            b--;
        }
        count++;
    }
    // count+=a-b;
    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:59:05
Judged At
2024-11-11 03:37:53
Judged By
Score
60
Total Time
32ms
Peak Memory
816.0 KiB