#include<bits/stdc++.h>
#define sf scanf
#define pf printf
#define LL long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
LL T;
cin >> T;
while(T--){
LL x , y;
cin >> x >> y;
LL diff = abs(x-y) , start = 1 , cnt = 0;
bool flag = false;
while(diff > 0){
diff-=start;
cnt++;
if(flag)start++;
flag=!flag;
}
cout << cnt << '\n';
}
return 0;
}
#define sf scanf
#define pf printf
#define LL long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
LL T;
cin >> T;
while(T--){
LL x , y;
cin >> x >> y;
LL diff = abs(x-y) , start = 1 , cnt = 0;
bool flag = false;
while(diff > 0){
diff-=start;
cnt++;
if(flag)start++;
flag=!flag;
}
cout << cnt << '\n';
}
return 0;
}
No comments:
Post a Comment