topic:
Solution:
If you write this question directly in divisible blocks, it will be t, but unfortunately I didn't see the pattern even after playing the watch during the game. o(╥﹏╥)o It
can be found that for x<sqrt(n), the answer must be x. Then we can find that the number between 1 and sqrt(n) will definitely appear, then we can calculate which n/x is the largest of these numbers. Because it is symmetric, we can calculate how many numbers there are in the other half, and add Going up is the answer.
You can see this picture to understand.
Code:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#define iss ios::sync_with_stdio(false)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int>pii;
const int MAXN=1e5+5;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double pi=acos(-1);
int main()
{
int t;
cin>>t;
while(t--){
int n,x;
cin>>n>>x;
if(x<sqrt(n)){
printf("%d\n",x);
continue;
}
int cnt;
int res=sqrt(n);
if(n/res==res){
cnt=res-1;
}
else{
cnt=res;
}
int c=n/x;
printf("%d\n",res-c+1+cnt);
}
}