数论
牛郎恋刘娘,刘娘念牛郎
裂开来
展开
-
[NOIP2002 普及组] 选数 dfs筛素数
突然想做个题n个数 选k个k个数的和为素数这种组合一共多少个end#include<bits/stdc++.h>using namespace std;typedef long long LL;LL prime[6] = {2, 3, 5, 233, 331};LL qmul(LL x, LL y, LL mod) { // 乘法防止溢出, 如果p * p不爆LL的话可以直接乘; O(1)乘法或者转化成二进制加法 return (x * y - (long原创 2021-11-29 21:29:32 · 178 阅读 · 0 评论 -
火车进栈出栈问题(卡特兰+大数+唯一分解)
*********卡特兰由于n 6000 阶乘需要借助高精度 压9位 速度更快题目经过卡特兰得出 最后公式为 2n!/((n!)^2*(n+1)!)唯一分解 将分子 分解 分母分解 最终得出每个质因子出现多少次 相乘即可#include<bits/stdc++.h>#include<iostream>#include<algorithm> using namespace std;typedef long long ll;const int ma原创 2021-10-30 19:46:04 · 96 阅读 · 0 评论 -
唯一分解模板
void p(int n) //线性筛质数{ for(int i=2;i<=n;i++) { if(!st[i]) primes[co++]=i; for(int j=0;primes[j]<=n/i;j++) { st[i*primes[j]]=true; if(i%primes[j]==0) break; } }}int calc(in..原创 2021-10-30 18:38:13 · 79 阅读 · 0 评论