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=( ...
随机推荐
- 洛谷P3383 【模板】线性筛素数 (埃拉托斯特尼筛法)
题目描述 如题,给定一个范围N,你需要处理M个某数字是否为质数的询问(每个数字均在范围1-N内) 输入输出格式 输入格式: 第一行包含两个正整数N.M,分别表示查询的范围和查询的个数. 接下来M行每行 ...
- SVN配置详解
原文:http://swjr.blog.com.cn/archives/2006/TheRoadToSubversion1authz.shtml http://www.dayuer.com/freeb ...
- [Usaco2013 Nov]No Change
Description Farmer John is at the market to purchase supplies for his farm. He has in his pocket K c ...
- C#方法的一些规则
C# 方法 一个方法是把一些相关的语句组织在一起,用来执行一个任务的语句块.每一个 C# 程序至少有一个带有 Main 方法的类. 要使用一个方法,您需要: 定义方法 调用方法 下面是方法的各个元素: ...
- DFS POJ 1321 棋盘问题
题目传送门 /* DFS:因为一行或一列都只放一个,可以枚举从哪一行开始放,DFS放棋子,同一列只能有一个 */ #include <cstdio> #include <algori ...
- canvas学写一个字
第一步:画一个米字格,先画一个矩形,再画中间的米字. <script> window.onload = function(){ var canvas = document.getEleme ...
- Python的I/O操作
1.读取键盘输入 msg = raw_input("Please enter :") print "you input ",msg #可接受Python表达式作 ...
- css样式获取及兼容性(原生js)
类选择器兼容性 getbyclass()类选择器,在IE8及以下均不可用. // 类选择器的兼容性 function getbyclass(parentName,Name){ var parentNa ...
- ORACLE 字符串补零
标准函数Lpad 可以实现左补零,但是如果多于需要长度,则会截断字符串.如下:-----------------------情况一:需要补零. SELECT LPAD ('1234' , ...
- C++(变量类型-深入)
变量类型 变量其实只不过是程序可操作的存储区的名称.C++ 中每个变量都有指定的类型,类型决定了变量存储的大小和布局,该范围内的值都可以存储在内存中,运算符可应用于变量上. 变量的名称可以由字母.数字 ...