Wrong Answer
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