随笔分类 -  数论

摘要:1078 Hashing (25分) The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of 阅读全文
posted @ 2020-06-14 23:35 Cruel_King 阅读(177) 评论(0) 推荐(0)
摘要:1049 Counting Ones (30分) The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of th 阅读全文
posted @ 2020-05-29 21:46 Cruel_King 阅读(127) 评论(0) 推荐(0)
摘要:我把自己演哭了... 心酸.jpg 写了很多个版本的,包括数学公式暴力,快速幂TLE等等,最后想到了优化快速幂里的乘法,因为会爆longlong,但是和别人优化的效率简直是千差万别...? 本题大意: 给定三个longlongint范围内的正整数a, b, c,求出a^b mod c 的结果并输出。 阅读全文
posted @ 2019-03-10 22:12 Cruel_King 阅读(232) 评论(0) 推荐(0)
摘要:本题大意:给出一个1000位以内的大数和一个小数,让你计算并给出大数对小数取余的结果。 本题思路:由下面的公式可以推出本题的计算公式,套入即可解决,建议自己把这个公式推一下,很简单的... 参考代码: 1 #include <cstdio> 2 #include <cstring> 3 using 阅读全文
posted @ 2019-03-10 02:38 Cruel_King 阅读(289) 评论(0) 推荐(0)
摘要:首先介绍一下线性筛,之所以称之为线性筛是因为它的复杂度为O(n)。 与埃氏筛相比,欧拉筛不会对已经被标记过的合数再进行重复标记,它们保证每个合数只会被它的最小质因数筛去故效率更高。欧拉筛将合数分解为 (最小质因数 * 一个合数) 的形式,通过最小质因数来判断当前合数是否已经被标记过。 2020-03 阅读全文
posted @ 2019-03-05 23:56 Cruel_King 阅读(1365) 评论(3) 推荐(1)
摘要:给出一篇有关素数线性筛和区间筛的博客,有兴趣的读者可以自取。 本题大意: 给定两个四位的素数,没有前导零,每次变换其中的一位,最终使得两个素数相等,输出最小变换次数。要求变换过程中的数也都是素数。 本题思路: 求最小步数,用BFS,判断素数,用欧拉筛打表。 参考代码: 1 #include <cst 阅读全文
posted @ 2019-03-05 21:23 Cruel_King 阅读(228) 评论(0) 推荐(0)