/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 0ms 284.0 KiB
#2 Accepted 0ms 332.0 KiB
#3 Accepted 0ms 420.0 KiB
#4 Accepted 33ms 696.0 KiB
#5 Accepted 34ms 500.0 KiB

Code

#include <stdio.h>

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

    for (int i = 0; i < T; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        
        int i = 0;
        while (A < B) {
            if (B % 2 == 0 && B / 2 >= A)
                B /= 2;
            else
                B -= 1;
            i++;
        }

        printf("%d\n", i + (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 17:22:21
Judged At
2024-03-27 17:22:21
Judged By
Score
100
Total Time
34ms
Peak Memory
696.0 KiB