注意到,本题用二分解决:

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define debug(x) cerr << #x << ": " << x << '\n';
const int INF = 0x3f3f3f3f3f3f3f3f;
//倒序不要忘记是--不是++
const int N=505050;
int fac[N];
void solve(){
    int a,b;cin>>a>>b;
    int mx=max(a,b);
    auto it=lower_bound(fac,fac+N,mx)-fac;
    if((it&1)&&(a==b)&&mx==fac[it]){
        cout<<it+1<<"\n";
    }
    else cout<<it<<"\n";
}
signed main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int t = 1;
    cin>>t;
    for(int i=1;i<=N-1;i++) fac[i]=(i*i+1)/2;
    while(t--){
        solve();
    }return 0;
}