Inserted a plate to make this figure represents +1, the problem is converted to the length of the sequence 1 ~ n, rl insertion plates (inclusive card may be, not limited to the number of each point plate), there are many kinds of programs, i.e., seeking $ \ sum_ {i = 1} ^ {n} c (rl + i, rl) $
considering this formula, supplemented on a c (rl + 1, rl + 1), the original formula = $ \ sum_ {I = 1} ^ {n} c (rl + i, rl) + c (rl + 1, rl + 1) -1 = \ sum_ {I = 2} ^ {n} c (rl + i, rl) + c (rl + 2, rl + 1) -1 = ...... = c (rl + n + 1, rl + 1) -1 $ , can be calculated by Lucas
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define mod 1000003 4 int t,n,l,r,fac[mod],inv[mod]; 5 int c(int n,int m){ 6 if (n<m)return 0; 7 return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod; 8 } 9 int main(){ 10 scanf("%d",&t); 11 fac[0]=inv[0]=inv[1]=1; 12 for(int i=1;i<mod;i++)fac[i]=1LL*fac[i-1]*i%mod; 13 for(int i=2;i<mod;i++)inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod; 14 for(int i=2;i<mod;i++)inv[i]=1LL*inv[i-1]*inv[i]%mod; 15 while (t--){ 16 scanf("%d%d%d",&n,&l,&r); 17 l=r-l+1; 18 printf("%lld\n",(1LL*c((n+l)/mod,l/mod)*c((n+l)%mod,l%mod)+mod-1)%mod); 19 } 20 }