随笔分类 - 数论
摘要:一、题目 super_log 二、分析 公式很好推出来,就是$$a^{a^{a^{a^{...}}}}$$一共是$b$个$a$。 对于上式,由于指数太大,需要降幂,这里需要用到扩展欧拉定理: 用这个定理时,除了$\gcd (a,p) =1$的情况,其他情况主要是保证$a$的指数不为$0$,在写代码的
阅读全文
摘要:一、题目 P1962 斐波那契数列 二、分析 比较基础的递推式转换为矩阵递推,这里因为$n$会超出$int$类型,所以需要用矩阵快速幂加快递推。 三、AC代码
阅读全文
摘要:一、题目 #124. 除数函数求和 二、分析 比较好的一题,首先我们要对题目和样例进行分析,明白题目的意思。 由于对于每一个$d$,它所能整除的数其实都是定的,且数量是$ \lfloor \frac{n}{d} \rfloor $ 最终推导出这个公式 $$ ans = \sum_{d=1}^{n}
阅读全文
摘要:一、题目 P2260 [清华集训2012]模积和 二、分析 参考文章:click here 具体的公式推导可以看参考文章。博主的证明很详细。 自己在写的时候问题不在公式推导,公式还是能够比较顺利的推导出来,但是,码力不够,比如说在乘积的时候,因为输入时候的$n$和$m$没有注意,一直用的$int$类
阅读全文
摘要:一、题目 P2424 约数和 二、分析 因为都是加法,那么肯定有的一个性质,即前缀和的思想,就是$$ { ans =\sum_{i=1}^y f(i)} - {\sum_{i=1}^x f(i)} $$ 基于上面的性质,分析$ \sum_{i=1}^x f(i) $,因为每个数都是因子之和,那么$1
阅读全文
摘要:一、题面 P2261 [CQOI2007]余数求和 二、分析 参考文章:click here 对于整除分块,最重要的是弄清楚怎样求的分得的每个块的范围。 假设$ n = 10 ,k = 5 $ $$ i : 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7 \ 8 \ 9 \ 10 \\ \lfl
阅读全文
摘要:题目: Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a probl
阅读全文
摘要:一、题目 Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his
阅读全文
摘要:一、题目 A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin
阅读全文
摘要:一、题目 The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged
阅读全文
摘要:一、题目 We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x i mod p) | 1 <= i <= p-1 } is equal to { 1,
阅读全文
摘要:一、题目 Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there
阅读全文
摘要:一、引文 1.欧拉函数:指不超过n且与n互素的正整数的个数,其中,n是一个正整数。 二、相关知识 1.算数函数:定义在所有正整数上的函数称为算数函数。 2.乘性函数(积性函数):对算数函数ƒ 如果满足对任意两个互素的正整数n和m,均有ƒ(nm)=ƒ(n)ƒ(m)。 3.完全乘性函数(完全积性函数):
阅读全文
摘要:引文:如果要对比较大的整数分解,显然之前所学的筛选法和是试除法都将不再适用。所以我们需要学习速度更快的Pollard_Rho算法。 算法原理: 生成两个整数a和b,计算p=gcd(a-b, n),知道p不为1或a,b出现循环为止,若p=n,则n为质数,否则p为n的一个约数。 对于如何生成这两个数,选
阅读全文
摘要:定义:给出一个正整数,将其携程几个素数的乘积,这个过程称为整数分解。 例题:HDU_1164 https://vjudge.net/problem/HDU-1164 一、试除法 算法:令m = n,从2~sqrt(N) 一一枚举,如果当前数能够整除m,那么当前数就是n的素因子,并用整数m将当前数除尽
阅读全文
摘要:引语:在数论中,对于素数的研究一直就很多,素数测试的方法也是非常多,如埃式筛法,6N±1法,或者直接暴力判(试除法)。但是如果要判断比较大的数是否为素数,那么传统的试除法和筛法都不再适用。所以我们需要学习Miller_Rabin算法。 知识准备 + 算法推导: 1.威尔逊定理:若p是素数,则 (p-
阅读全文

浙公网安备 33010602011771号