/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 0ms 284.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 36ms 712.0 KiB
#5 Accepted 37ms 644.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-11-11 03:37:37
Judged By
Score
100
Total Time
37ms
Peak Memory
712.0 KiB