【参考代码】

#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;
}

bzoj4403题解的更多相关文章

  1. 【BZOJ4403】序列统计(组合数学,卢卡斯定理)

    [BZOJ4403]序列统计(组合数学,卢卡斯定理) 题面 Description 给定三个正整数N.L和R,统计长度在1到N之间,元素大小都在L到R之间的单调不降序列的数量.输出答案对10^6+3取 ...

  2. 【BZOJ4403】序列统计 Lucas定理

    [BZOJ4403]序列统计 Description 给定三个正整数N.L和R,统计长度在1到N之间,元素大小都在L到R之间的单调不降序列的数量.输出答案对10^6+3取模的结果. Input 输入第 ...

  3. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  4. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  5. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  6. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  7. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  8. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  9. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

随机推荐

  1. 【leetcode】908. Smallest Range I

    题目如下: 解题思路:简单的不能再简单的题目了,对于任意一个A[i]来说,其可能的最小的最大值是A[i]-K,最大的最小值是A[i]+K.遍历数组,求出所有元素中最大的最小值和最小的最大值,两者之差( ...

  2. 【leetcode】948. Bag of Tokens

    题目如下: You have an initial power P, an initial score of 0 points, and a bag of tokens. Each token can ...

  3. c++11引入特性

    * 支持类内初始化. class A{ vector<string> strs{"abc", "def"}; };

  4. Reverse array

    数组颠倒算法 #include <iostream> #include <iterator> using namespace std; void reverse(int* A, ...

  5. Linux系统Centos查看IP地址,不显示IP地址或者显示127.0.0.1

    1.桌面界面 右上角有个电脑的图标,鼠标悬停会显示no network connect 点击一下图标,选择连接的网络则ok 2.命令行界面 在命令行界面输入 vi  /etc/sysconfig/ne ...

  6. (3)C++复合类型

    存储数据时必须跟踪的三个属性:信息储存在何处,存储的值,存储的类型 一.数组 #include <iostream> using namespace std; int main() { / ...

  7. 9、继续matlab数值分析

    1.matlab拉格朗日插值 function yi=Lagrange(x,y,xi) %x为向量,全部的插值节点 %y为向量,插值节点处的函数值 %xi为标量或向量,被估计函数的自变量: %yi为x ...

  8. 4、jQuery面向对象之简单的插件开发

    1.alert例子 (function($){ $.alert = function(msg){ window.alert(msg); } $.fn.alert = function(msg){ wi ...

  9. mybatis的sqlprovider用法扩展自定义sql

    SqlProvider使用 public class MemberRewardSqlProvider { private static final Logger log = LoggerFactory ...

  10. numpy 中文手册

    https://yiyibooks.cn/xx/NumPy_v111/user/index.html