// I SELL YOU...! #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; using TP = tuple; void init_io(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } map mp; double calc(ll v) { auto itr = mp.find(v); if (itr != mp.end()) { return itr->second; } double s = 1, e = v; for (int i=0;i<100;i++) { double h = (s+e)/2; if (h*h < v) { s = h; } else { e = h; } } mp[v] = (s+e)/2; return (s+e)/2; } signed main(){ const ll MAX = 1e9+2; map p; for (ll i=1;i*i<=MAX;i++) { p[i*i] = i; } init_io(); ll n; cin >> n; vector a(n), b(n); for (int i=0;i> a[i] >> b[i]; ll ans; auto ia = p.find(a[i]), ib = p.find(b[i]); if (ia != p.end() && ib != p.end()) { ans = ia->second + ib->second + 1; } else { ans = ceil(calc(a[i]) + calc(b[i])); } cout << ans << endl; } }