bzoj4403题解

【参考代码】
#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题解的更多相关文章
- 【BZOJ4403】序列统计(组合数学,卢卡斯定理)
[BZOJ4403]序列统计(组合数学,卢卡斯定理) 题面 Description 给定三个正整数N.L和R,统计长度在1到N之间,元素大小都在L到R之间的单调不降序列的数量.输出答案对10^6+3取 ...
- 【BZOJ4403】序列统计 Lucas定理
[BZOJ4403]序列统计 Description 给定三个正整数N.L和R,统计长度在1到N之间,元素大小都在L到R之间的单调不降序列的数量.输出答案对10^6+3取模的结果. Input 输入第 ...
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...
- 2016ACM青岛区域赛题解
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- poj1399 hoj1037 Direct Visibility 题解 (宽搜)
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...
随机推荐
- mui-popover显示、隐藏弹出菜单的方法
一.mui-popover要显示.隐藏弹出菜单,可使用锚点方式. <div id="popover" class="box mui-popover mui-popp ...
- qt学习(四)主窗选钮,显示新窗口。
游戏有选区这个习惯, 当然,我特指<冒险岛>了,有的时候就是打开一个主屏幕上五个按钮让你点击进入, 甚至有的时候进去了还要选哪个频道,游戏服务器都得分区,频道来完成功能.现在我们先进入想选 ...
- CSS分组和嵌套选择器
CSS 分组 和 嵌套 选择器 分组选择器 在样式表中有很多具有相同样式的元素.直线模组哪家好 h1 { color:green; } h2 { color:green; } p { ...
- Vuetify按需加载配置
自己配置vuetify按需加载的步骤,在此记录: 执行npm install vuetify –save 或 yarn add vuetify添加vuetify添加依赖执行npm install -- ...
- CSS 设置鼠标显示形状
CSS 设置鼠标显示形状 <style type="text/css"><!-- span {display:block;line-height:30px;mar ...
- SQL server 2012序列号 注册码
企业核心版: FH666-Y346V-7XFQ3-V69JM-RHW28 商业智能版: HRV7T-DVTM4-V6XG8-P36T4-MRYT6 开发版: YQWTX-G8T4R-QW4XX-BVH ...
- Git与GitHub同步
如何通过Git Bash实现本地与远端仓库——GitHub的同步 1.下载安装Git:下载网址 2.在自己的github上新建一个repository 例如我这里新建了一个叫test的reposito ...
- CodeForces - 841B-Godsend-思维
Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two pla ...
- Python List列表的操作说明
Python中List的N种操作,其简单程度令人叹为观止... C:\Users\rhys>python Python 2.7.14 (v2.7.14:84471935ed, Sep 16 20 ...
- 使用soapui进行webservice接口测试
一.web service(SOAP)与HTTP接口的区别 1.什么是web service WebService就是Web服务的意思,对应的应用层协议为SOAP(相当于HTTP协议),可理解为远 ...