当前位置:网站首页>Find the combination number acwing 888 Find the combination number IV
Find the combination number acwing 888 Find the combination number IV
2022-07-05 06:24:00 【T_ Y_ F666】
Find the combination number AcWing 888. Find the combination number IV
Original link
AcWing 888. Find the combination number IV
Algorithm tags
Combinatorial mathematics Combination count High precision
Ideas


Code
#include<bits/stdc++.h>
#define int long long
#define abs fabs
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>=b;--i)
using namespace std;
const int N = 5015;
int pr[N], st[N], s[N], cnt;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
void pri(int n){
rep(i, 2, n+1){
if(!st[i]){
pr[cnt++]=i;
}
for(int j=0; pr[j]<=n/i; ++j){
st[pr[j]*i]=true;
if(!(i%pr[j])){
break;
}
}
}
}
int get(int n, int p){
int res=0;
while(n){
res+=n/p;
n/=p;
}
return res;
}
vector<int> mul(vector<int> a, int b){
vector<int> c;
int t=0;
rep(i, 0, a.size()){
t+=a[i]*b;
c.push_back(t%10);
t/=10;
}
while(t){
c.push_back(t%10);
t/=10;
}
return c;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int a=read(), b=read();
pri(a);
rep(i, 0, cnt){
int p=pr[i];
s[i]=get(a, p)-get(a-b, p)-get(b, p);
}
vector<int> res;
res.push_back(1);
rep(i, 0, cnt){
rep(j, 0, s[i]){
res=mul(res, pr[i]);
}
}
Rep(i, res.size()-1, 0){
printf("%lld", res[i]);
}
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- 【LeetCode】Day95-有效的数独&矩阵置零
- [2020]GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis
- Leetcode-556: the next larger element III
- [rust notes] 14 set (Part 1)
- Simple selection sort of selection sort
- How to understand the definition of sequence limit?
- Records of some tools 2022
- TCP's understanding of three handshakes and four waves
- Shutter web hardware keyboard monitoring
- 阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
猜你喜欢

MySQL advanced part 2: the use of indexes

Matrixdb V4.5.0 was launched with a new mars2 storage engine!
![[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields](/img/65/7fa32cd0005ddaaebacd85c25e0c7e.jpg)
[2021]GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields

Redis-01.初识Redis

1.14 - assembly line

Open source storage is so popular, why do we insist on self-development?

Is it impossible for lamda to wake up?

P2575 master fight

SQL三种连接:内连接、外连接、交叉连接

中国剩余定理 AcWing 204. 表达整数的奇怪方式
随机推荐
Usage scenarios of golang context
Alibaba established the enterprise digital intelligence service company "Lingyang" to focus on enterprise digital growth
MySQL advanced part 2: storage engine
2.Oracle-数据文件的添加及管理
MySQL advanced part 2: the use of indexes
Record the process of configuring nccl and horovod in these two days (original)
Redis-01.初识Redis
5.Oracle-表空间
RecyclerView的应用
Leetcode-6109: number of people who know secrets
在新线程中使用Handler
Leetcode divide and conquer / dichotomy
Is it impossible for lamda to wake up?
Open source storage is so popular, why do we insist on self-development?
[BMZCTF-pwn] ectf-2014 seddit
Leetcode heap correlation
MySQL advanced part 1: View
Gaussian elimination acwing 884 Gauss elimination for solving XOR linear equations
区间问题 AcWing 906. 区间分组
ADG5412FBRUZ-RL7应用 双电源模拟开关和多路复用器IC