上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 适用范围:较大数的较快素性判断 思路: 因为有好的文章讲解具体原理(见参考文章),这里只是把代码的大致思路点一下,读完了文章如果还有些迷糊,可以参考以下解释 原理是费马小定理:如果p是素数,则a^(p-1)%p==1,加上二次探测定理:如果p是一个素数,则x^2%p==1的解为,则x=1或者x=n- 阅读全文
posted @ 2019-07-28 10:14 小张人 阅读(3272) 评论(0) 推荐(0) 编辑
摘要: 快速幂: 计算a^n%p的值,怎么算呢?直接算当然可能溢出。我们有一条引理:(a*b)%p=((a%p)*(b%p))%p.在这个引理上进行指数上的合并从而得到快速幂算法。 具体地,有两种思路,一种是减小a值,以防溢出,一种是减小b值,加快计算。 怎么减小a值?a=a%p,就把a的值降到了p以下。对 阅读全文
posted @ 2019-07-28 00:24 小张人 阅读(992) 评论(0) 推荐(0) 编辑
摘要: 题目描述: F. Ant colonytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMole is hungry again. He found 阅读全文
posted @ 2019-07-27 20:50 小张人 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 思想: 先用字符串来读入大整数,然后用数组来存储大整数。与上一篇的所讲思路不同的是,这次是数组的每一个元素对应大整数的一个数,从而模拟手算过程。 主要实现思路与手算无太大差别。主要是一些细节上。 统一做个说明:模拟大数的数组的第零个元素保存的是数字个数(不包括第零个元素),而且数组从1到尾分别存大数 阅读全文
posted @ 2019-07-27 16:37 小张人 阅读(815) 评论(0) 推荐(0) 编辑
摘要: 思想: 由于编程语言提供的基本数值数据类型表示的数值范围有限,不能满足较大规模的高精度数值计算,因此需要利用其他方法实现高精度数值的计算,于是产生了大数运算。大数运算主要有加、减、乘三种方法。 考虑用数组存储整数,并模拟手算的方法进行加减乘除四则运算。为了能像int一样方便的使用大整数,可以定义结构 阅读全文
posted @ 2019-07-27 16:00 小张人 阅读(768) 评论(0) 推荐(1) 编辑
摘要: 题目描述: time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDima worked all day and wrote down on a lo 阅读全文
posted @ 2019-07-27 15:30 小张人 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 题目描述: D. Vus the Cossack and Numbers Vus the Cossack has nn real numbers aiai. It is known that the sum of all numbers is equal to 00. He wants to cho 阅读全文
posted @ 2019-07-26 16:31 小张人 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Nick had received an awesome array of integers a=[a1,a2,…,an] as a gift for his 5 birthday from his mother. He was already going to explore its 阅读全文
posted @ 2019-07-26 13:16 小张人 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 题目描述: D. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output D. Color the Fe 阅读全文
posted @ 2019-07-26 10:36 小张人 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 题目描述: H. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output 题目描述: H. Maximal GCD 阅读全文
posted @ 2019-07-26 10:13 小张人 阅读(263) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页
分享到: