请解释如下代码:
\(View\) \(Code\)
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int ret=0,f=1;
char ch=getchar();
while(ch>'9'||ch<'0')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
ret=(ret<<1)+(ret<<3)+ch-'0';
ch=getchar();
}
return ret*f;
}
inline long long readl()
{
long long ret=0;
int f=1;
char ch=getchar();
while(ch>'9'||ch<'0')
{
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
ret=(ret<<1)+(ret<<3)+ch-'0';
ch=getchar();
}
return ret*f;
}
int n,t,k;
long long m,C[75][75],l,r;
inline void pre()
{
C[0][0]=1;
for(register int i=1;i<=67;i++)
{
C[i][0]=1;
for(register int j=1;j<=i;j++)
C[i][j]=C[i-1][j-1]+C[i-1][j];
}
}
inline long long calc(int k,long long m)
{
if(m==-1)
return 0;
long long ret=0;
while(k)
{
int pos=k;
while(C[pos][k]<=m)
pos++;
pos--;
ret|=1ll<<pos;
m-=C[pos][k];
k--;
}
return ret;
}
int main()
{
t=read();
pre();
while(t--)
{
m=readl();
k=read();
k--;
if(!k)
printf("1 -1\n");
else
{
r=calc(k,m);
l=calc(k,m-1);
printf("%lld %lld\n",l+1ll,r-l);
}
}
return 0;
}