/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 0ms 320.0 KiB
#2 Wrong Answer 0ms 320.0 KiB

Code

#include <stdio.h>

// Function to find minimum operations to make A equal to B
int minOperations(int A, int B) {
    int operations = 0;
    // Keep applying operations until A becomes equal to or greater than B
    while (A < B) {
        // If doubling A makes it greater than or equal to B, then double it
        if (A * 2 >= B) {
            A *= 2;
        }
        // Otherwise, increment A
        else {
            A++;
        }
        operations++; // Increment the count of operations
    }
    return operations;
}

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        int A, B;
        scanf("%d %d", &A, &B);
        printf("%d\n", minOperations(A, B));
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1044 Add or multiple
Contest
TLE_Headquarters - round #1
Language
C99 (GCC 13.2.0)
Submit At
2024-03-27 16:15:14
Judged At
2024-11-11 03:39:18
Judged By
Score
0
Total Time
0ms
Peak Memory
320.0 KiB