【参考代码】
#pragma GCC optimize(2)
#include <cstdlib>
#define function(type) __attribute__((optimize("-O2"))) inline type
#define procedure __attribute__((optimize("-O2"))) inline void
using namespace std;
//quick_io {
#include <cctype>
#include <cstdio>
function(long long) getint()
{
char c=getchar(); for(;!isdigit(c)&&c!='-';c=getchar());
short s=1; for(;c=='-';c=getchar()) s*=-1; long long r=0;
for(;isdigit(c);c=getchar()) r=(r<<3)+(r<<1)+c-'0';
return s*r;
}
//} quick_io
static const int AwD=1000003;
function(int) format(const int&x) {return x+(x<0)*AwD;}
function(int) mrev(const int&x)
{
int ret=1,bas=x;
for(register int i=AwD-2;i;i>>=1,bas=1ll*bas*bas%AwD)
{
if(i&1) ret=1ll*ret*bas%AwD;
}
return ret;
}
int fact[AwD]={1};
function(int) Lucas(const int&m,const int&n)
{
div_t M=div(m,AwD),N=div(n,AwD);
if(M.quot<N.quot||M.rem<N.rem) return 0;
return 1ll*fact[M.quot]*fact[M.rem]*mrev(
1ll*fact[N.quot]*fact[N.rem]%AwD*fact[M.quot-N.quot]*fact[M.rem-N.rem]%AwD
)%AwD;
}
int main()
{
for(register int i=1;i<AwD;++i) fact[i]=1ll*fact[i-1]*i%AwD;
for(register int T=getint();T--;)
{
int n=getint(),l=getint(),r=getint();
printf("%d\n",format(Lucas(n-l+r+1,n)-1));
}
return 0;
}
We Secure, We Contain, We Protect.