/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Wrong Answer 2ms 328.0 KiB
#3 Wrong Answer 2ms 428.0 KiB

Code

#include<bits/stdc++.h>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ll long long int
using namespace std;

void solution();

int main() {
    faster
    int t = 1;
    cin >> t;
    while (t--) {
        solution();
    }
}

void solution() {
    int x, y;
    cin >> x >> y;
    if (x >= y) {
        cout << x - y << endl;
        return;
    }
    if (y % 2 == 0) {
        int op = 0;
        while (y > x) {
            y /= 2;
            op++;
        }
        cout << op + (x - y) << endl;
    } 
    else {
        y--;
        int op = 1;
        while (y > x) {
            y /= 2;
            op++;
        }
        cout << op + (x - y) << endl;
    }
}

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:27:54
Judged At
2024-11-11 03:37:35
Judged By
Score
20
Total Time
2ms
Peak Memory
428.0 KiB