Accepted
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