牛牛与整除分块 题解(打表+思维)
题目链接
题目思路
不会啊qwq,然后打表,结果没找出规律
直接看官方题解
代码
#include<bits/stdc++.h>
#define fi first
#define se second
#define debug cout<<"I AM HERE"<<endl;
using namespace std;
typedef long long ll;
const int maxn=1e5+5,inf=0x3f3f3f3f,mod=1e9+7;
const int eps=1e-6;
int x,n;
signed main(){
int _; scanf("%d",&_);
while(_--){
scanf("%d%d",&x,&n);
int mid=sqrt(x),ans,sum;
if(x/mid==mid){
sum=2*mid-1;
}else{
sum=2*mid;
}
if(n<=mid){
ans=n;
}else{
ans=sum-x/n+1;
}
printf("%d\n",ans);
}
return 0;
}
不摆烂了,写题