数
文章平均质量分 71
就是xyz
这个作者很懒,什么都没留下…
展开
-
调和级数与整除分块
LightOJ - 1234(保留小数)In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers:In this problem, you are given n, you have to find Hn.InputInput st...原创 2018-08-28 09:43:28 · 286 阅读 · 0 评论 -
莫比乌斯函数的求法
sqrt(n)求解莫比乌斯函数值,如果把素数筛出来会使求解莫比乌斯函数更快。ll getmu(ll n){ ll v=1; for(int i=2;i*i<=n;i++) if(n%i==0) { v=-v;n/=i; if(n%i==0)return 0; } if(n!=1)v=-v; r...原创 2018-09-28 15:53:50 · 1194 阅读 · 0 评论 -
HDU6265(能被n整除的因子与其欧拉乘积的和)
由这两个公式联立公式很显然我们可以消去d可以推出:我们知道对于每个pi,我们都有qi种取法,根据欧拉函数的性质我们知道每一个质数的的倍数的欧拉函数值 都等于这个质数的欧拉函数值等于其扩大的倍数,正好其外面缩小倍数也为其欧拉扩大的倍数,所以这组数对答案的贡献是相同的。我们可以通过类比的方法得到所有的答案:我们可以通过已经给的质因子知道他一共有多少因子,通过欧拉函数的性质我们可以将对答案贡...原创 2018-10-05 20:58:42 · 1152 阅读 · 0 评论 -
我的第一道杜教筛(莫比乌斯函数求和 51Nod-1244)
先总结一下,杜教筛的的精髓之处我认为在于通过两个积性函数做狄利克雷卷积以后就可以对其进行整除分块了,又因为一般用到杜教筛的题目数据量都特别大,是o(n)时间都跑不过来的数据,所以肯定不能预处理。但是这样的题样例数量不会太大,你只能每一次都计算结果,不能与处理出来结果,所以你需要用到记忆化搜索或hashmap去存整除分块的过程中出现的s(n)。以后用到s(n)可以o(sqrt(n))查询调用。记...原创 2018-10-04 11:26:57 · 316 阅读 · 0 评论 -
经典小知识融合数论题(hdu-5528)
B - Count a * b HDU - 5528 Marry likes to count the number of ways to choose two non-negative integers a and b less than m to make a×b mod m≠0.Let's denote f(m) as the number of ways to choose tw...原创 2018-10-02 16:04:35 · 299 阅读 · 0 评论 -
逆元的几种求法
1、快速幂直接求(要求取模的数为质数)由费马小定理可得,如果p为质数,则a^(p-1)%c=1=a*a^(p-2)%c;如果a*b%mod=1;则a为b的逆元,b也为a的逆元。a的逆元为a^(mod-2).ll pow_mod(ll a,ll b){ ll res=1; while(b){ if(b&1) res=res*a%mod; b...原创 2018-10-01 10:49:17 · 1129 阅读 · 0 评论 -
异或和与组合数(HDU - 4810)按二进制位拆分
Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, she produces a wonderful color of pigments by mixing water and some bags of pigments. On the K-...原创 2018-09-24 20:21:48 · 566 阅读 · 0 评论 -
莫比乌斯反演前缀和除法分块优化(hdu4746)
C - Mophues HDU - 4746 As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime numbers: C = p1×p2× p3× ... × pk which p1, p2 ... pk are all prime number...原创 2018-09-17 10:50:59 · 277 阅读 · 0 评论 -
判断lcm超过ll 和开n次方根的精确值
判断x开pos次方根的精确值:用pow(x,1/pos)开的话,每次开平方根都是保留的整数。会导致精度的缺失,当pos大的话开出来的值就会出现误差。但误差一般在开出来的值 与正确答案的误差在|1|以内。ll qpow(ll a, ll b) {//快速幂 ll ans = 1; while(b) { if(b&1) { doubl...原创 2018-09-12 15:24:21 · 162 阅读 · 0 评论 -
2018 ICPC 沈阳网络赛 G. Spare Tire 1到n中与m互质的平方和与本身和
计蒜客全部课程 学习计划 题库 比赛 Spare Tire编辑代码 15.27% 1000ms 131072KA sequence of integer \lbrace a_n \rbrace{an} can be expressed as: \displaystyle a_n = \left\{ \begin{array}{lr} 0, & n=...原创 2018-09-08 22:12:02 · 263 阅读 · 0 评论 -
gcd的小特性
由UVA - 11426学到的小知识由于数据量为4×le6,我们暴力跑答案不算gcd的时间的话还要1e13。大致需要10000s.所以我们需要预处理一些值。直接就往分块想,我们知道gcd(1,n)、 gcd(2,n)……………gcd(n-1,n)里有很多对的gcd是相同的。而gcd(x,n)=i等价于gcd(x/i,n/i)=1,因此gcd为i的个数为phi(n/i)。因此我们可以通过...原创 2018-09-02 19:54:17 · 486 阅读 · 0 评论 -
2018ICPC南京网络赛(线性筛预处理与整除分块)J题sum
1000ms 512000KA square-free integer is an integer which is indivisible by any square number except 11. For example, 6 = 2 * 3=1⋅6 is square-free, but 12 = 2^2 *3 is not, because 2^2 is a square num...原创 2018-09-02 12:56:28 · 202 阅读 · 0 评论 -
另类容斥和欧拉函数巧妙应用(HDU--5514)
There are mm stones lying on a circle, and nn frogs are jumping over them. The stones are numbered from 00 to m−1m−1 and the frogs are numbered from 11 to nn. The ii-th frog can jump over exactly aia...原创 2018-09-30 20:18:39 · 171 阅读 · 0 评论