bzoj——2982: combination
2982: combination
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 611 Solved: 368
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
5 1
5 2
7 3
4 2
Sample Output
10
35
6
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 10008
#define ll long long
#define mod 10007
using namespace std;
ll t,n,m,ans,f[N];
ll read()
{
ll x=,f=; char ch=getchar();
; ch=getchar();}
+ch-'; ch=getchar();}
return x*f;
}
ll qpow(ll n,ll k)
{
ll res=;
while(k)
{
) res=res*n%mod;
n=n*n%mod; k>>=;
}return res;
}
ll c(ll n,ll m)
{
;
)%mod;
}
ll lus(ll n,ll m)
{
) ;
return c(n%mod,m%mod)*lus(n/mod,m/mod)%mod;
}
int main()
{
t=read();f[]=;
;i<=mod;i++)
f[i]=f[i-]*i%mod;
while(t--)
{
n=read(),m=read();
ans=lus(n,m);
printf("%lld\n",ans);
}
;
}
bzoj——2982: combination的更多相关文章
- ZOJ 3557 & BZOJ 2982 combination[Lucas定理]
How Many Sets II Time Limit: 2 Seconds Memory Limit: 65536 KB Given a set S = {1, 2, ..., n}, n ...
- BZOJ 2982: combination( lucas )
lucas裸题. C(m,n) = C(m/p,n/p)*C(m%p,n%p). ----------------------------------------------------------- ...
- bzoj 2982 combination——lucas模板
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2982 明明是lucas定理裸题…… 非常需要注意C( )里 if ( n<m ) r ...
- BZOJ 2982 combination
lucas定理裸题. #include<iostream> #include<cstdio> #include<cstring> #include<algor ...
- BZOJ 2982 combination Lucas定理
题目大意:发上来就过不了审核了--总之大意就是求C(n,m) mod 10007 m,n∈[1,2*10^8] 卢卡斯定理:C(n,m)=C(n%p,m%p)*C(n/p,m/p) mod p 要求p ...
- BZOJ 2982 combination 脑子+组合数学
可以发现,整个数列构成一个树形结构,并且是个完全二叉堆(小根堆). 并且这个堆的形态在给定$n$后是固定的,第1个位置上显然只能放1. 对子树的根来说,他自己是所分得的数集中最小的那个,所以从剩下$s ...
- BZOJ 2982: combination Lucas模板题
Code: #include<bits/stdc++.h> #define ll long long #define maxn 1000003 using namespace std; c ...
- 【BZOJ 2982】 2982: combination (卢卡斯定理)
2982: combination Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 510 Solved: 316 Description LMZ有n个 ...
- 【BZOJ】2982: combination(lucas定理+乘法逆元)
http://www.lydsy.com/JudgeOnline/problem.php?id=2982 少加了特判n<m return 0就wa了QAQ lucas定理:C(n, m)%p=( ...
随机推荐
- python自动化测试学习笔记-6excel操作xlwt、xlrd、xlutils模块
python中通过xlwt.xlrd和xlutils操作xls xlwt模块用于在内存中生成一个xls/xlsx对象,增加表格数据,并把内存中的xls对象保存为本地磁盘xls文件; xlrd模块用于把 ...
- Spring.Net学习笔记(0)-错误汇总
1.错误一:ObjectDefinitionStoreException "Spring.Objects.Factory.ObjectDefinitionStoreException&quo ...
- npm install的时候报错 npm err code 1
在学习vue的时候,npm install的时候报错 npm err code 1,当时很郁闷,是‘vue init webpack my-project’命令新建的模版项目 ,怎么会报错,第一次遇 ...
- 微信小程序组件解读和分析:四、icon图标
icon图标组件说明: icon是一种图标格式,用于系统图标.软件图标等,这种图标扩展名为.icon..ico.常见的软件或windows桌面上的那些图标一般都是ICON格式的.在应用上面很多地方 ...
- Android中 string.xml资源 如何添加参数?
在android 开发,我们通常会用string.xml资源去设置textview等控件的字符串.而值一般是与程序的运行结果无关的. 但有时需要根据运行的结果来显示到控件中,这时字符串资源就不能写死了 ...
- 【C++】智能指针简述(二):auto_ptr
首先,我要声明auto_ptr是一个坑!auto_ptr是一个坑!auto_ptr是一个坑!重要的事情说三遍!!! 通过上文,我们知道智能指针通过对象管理指针,在构造对象时完成资源的分配及初始化,在析 ...
- 安装FCIS问题汇总
安装官网安装步骤时可能出现的问题: "/usr/bin/ld: cannot find -lopenblas" error 解决方案: apt install liblapack- ...
- 部署bugzilla(bugzilla+apache+mysql+linux)
工作原因,需要部署bugzilla.在此,容我新造个轮子.官方轮子:https://bugzilla.readthedocs.org/en/latest/installing/quick-start. ...
- Linux 报错 ifconfig command not found
1.Linux 中输入ifconfig命令报错:ifconfig command not found 有可能是没有安装ifconfig,如果没有,安装上去 2.查看是不是缺少了ifconfig,它是在 ...
- IIS发布403报错
报错信息如下图 解决方案,inetmgr打开IIS,找到对应网站的目录浏览,双击 开启