赛时因为快读没有开long long 喜获30pts
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N];
typedef long long ll;
int read()
{
int s=0,f=1;
char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-')f=-1;
ch=getchar();
}
while(isdigit(ch))
{
s=s*10+ch-'0';
ch=getchar();
}
return s*f;
}
void write(ll x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
}
int main()
{
int t=read();
while(t--)
{
ll n=read(),k=read();
if(k==0)
{
write(1);
puts("");
continue;
}
ll p1=n/(k+1)+1;
ll p2=n/k;
write(p2-p1+1);
puts("");
}
return 0;
}