当前位置:网站首页>Not so large number of combinations
Not so large number of combinations
2022-07-19 08:13:00 【2020100XWH】
Direct calculation
No matter how big and p 1e5 In this case, cooperate with Lucas to deal with
Linear inverse element
p-2 Inverse element
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+50;
int p,inv[N],a[N];
void invv()
{
inv[1]=1;
for(int i=2;i<=N;++i)
{
inv[i]=(p-(p/i))*inv[p%i]%p;
}
return ;
}
ll qpow(ll a,ll b)
{
ll ans=1;
while(b)
{
if(b&1)
{
ans=(ans*a)%p;
}
a=(a*a)%p;
b>>=1;
}
return ans;
}
ll mm(ll x)
{
return qpow(x,p-2);
}
ll c(ll n,ll m)
{
ll ans=1;
for(ll i=1,j=n-m+1;i<=m;++i,++j)
{
ans=(ans*mm(i))%p;
ans=(ans*j)%p;
}
return ans;
}
int main ()
{
int t;
cin>>t;
while(t--)
{
ll n,m;
cin>>n>>m>>p;
cout<<c(n,m)<<"\n";
}
return 0;
}边栏推荐
- Beijing Jiewen technology, an acquiring outsourcing service provider, transferred 60% of its shares for about 480million
- 在线问题反馈模块实战(五):实现对通用字段内容自动填充功能
- Array exercise 3
- WPF 三维应用搭建(基础)
- Facial key point detection CNN
- Practice of online problem feedback module (V): realize the automatic filling function of general field content
- 类型详解·自定义类型·结构体初识
- First experience of openvino machine learning
- 关于快慢指针的理解
- Local storage sessionstorage
猜你喜欢
随机推荐
First experience of openvino machine learning
ObjectARX--自定义圆的实现
Visual studio production environment configuration scheme: slowcheetah
Interview question: outer margin folding problem (bug of block level elements in ordinary document flow)
redis6新功能
Discussion sur la technologie RISC - V
【特征工程】
Redis distributed lock
YOLOV5-打标签建立自己的数据集
1669. Merge two linked lists (merge of two linked lists)
How to check whether the app has user information and data leakage vulnerabilities
Paddleserving服务化部署 tensorrt报错, shape of trt subgraph is [-1,-1,768],
Yolov5 label and establish your own data set
【flask入门系列】异常处理
redis事务
Csp-2020-6- role authorization
分叉币的发展史及价值|ETH、BCH、BSV 2020-03-08
MCU如何选型?
openvino机器学习初体验
通过ip获取归属地








![[C# 变量常量关键字]- C# 中的变量常量以及关键字](/img/9b/433f9110d9c7599d8beac8288ea409.png)
