时
化简可得
于是以为界,在左边或者右边找对应的位置即可。
#include <bits/stdc++.h>
#define sc(x) scanf("%lld", &(x))
#define pr(x) printf("%lld\n", (x))
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int mod = 1e9 + 7;
int main() {
ll T, n, x;
sc(T);
while (T--) {
sc(n), sc(x);
ll a = sqrt(n);
if (x <= a)
pr(x);
else {
ll l = n / a;
ll ans = 0;
if (a != l) ++ans;
ll now = n / x;
ans += a - now + a;
pr(ans);
}
}
return 0;
} 
京公网安备 11010502036488号