随笔分类 - 数论
摘要:描述 传送门:我是传送门 In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The co
阅读全文
摘要:描述 传送门:我是传送门 DreamGrid has nn integers a1,a2,…,ana1,a2,…,an. DreamGrid also has mm queries, and each time he would like to know the value of ∑1≤i≤n⌊ai
阅读全文
摘要:描述 传送门:我是传送门 Edward, the headmaster of the Marjar University, is very busy every day and always forgets the date. There was one day Edward suddenly fo
阅读全文
摘要:描述 传送门:我是传送门 Alice, a student of grade 66, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob
阅读全文
摘要:费马小定理 结论 假如p是质数,且gcd(a,p)=1,那么 a(p-1)≡1(mod p)。 即:假如a是整数,p是质数,且a,p互质(即两者只有一个公约数1),那么a的(p-1)次方除以p的余数恒等于1。 证明:传送门 推论:对于任意正整数a,有a^p ≡ a (mod p),因为a能被p整除时
阅读全文
摘要:描述 1 import java.util.*; 2 import java.math.*; 3 4 public class Main{ 5 public static void main(String [] args){ 6 Scanner in = new Scanner(System.in)
阅读全文
摘要:Miller_Rabin算法(素数判定) 作用 单独判断一个大数是否素数。缺点他是一个不保证正确的算法,我们只能通过多次执行算法让这个错误的概率很小,不过幸运的是通常来看它的错误概率可以小到忽略不计。 补充:【模板】素数测试(Miller-Rabin测试) 算法的理论基础 Fermat定理:若n是奇
阅读全文
摘要:当只需要求某个数是不是素数的时候,我们可以直接通过素数的定义来求,即如果可以被除1及素数本身的其他数整除,则这个数不是素数 但是如果要求某个范围内的素数的个数的时候这个方法就不太合适了。虽然我们可以进行预处理,但是这种方法比较慢,一旦范围过大,预处理过程便会超时。 因此,需要使用筛法求素数,这样可以
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=2048 没想到还真的有意外之喜,发现了自己的盲区,其实这道题我在大一的时候是见过的,但是当时不会就给跳过了 缘,妙不可言~ 错排公式
阅读全文
摘要:链接:http://acm.hdu.edu.cn/showproblem.php?pid=5832 题意:两个星球,一个星球一年只有137天,一个星球一年只有73天 输入N(爆炸后第N天),判断这是否为这两个星球的第一天 只要这个数是137与73的公倍数就好了(0比较特殊) 坑点:N的长度不超过10
阅读全文

浙公网安备 33010602011771号