
数学相关——基础数论
文章平均质量分 82
无
迷蒙之雨
这个作者很懒,什么都没留下…
展开
-
[THUPC2018]密码学第三次小作业
为负的情况需要特殊处理一下。,由裴蜀定理,必然存在。原创 2023-01-05 19:59:16 · 566 阅读 · 0 评论 -
[JSOI2018]机器人
计算答案时,考虑枚举撞到障碍的轮数,以及撞到的障碍,因为有循环节,所以所有循环节里州的路线是一样的,也就是说,如果第一轮走到了。现在给出若干障碍,对于每一个上述行走方案,走到障碍时会停止,求所有方案的行走的格子的个数和。,原因是每一步必定会到下一个对角线,所以该序列和对角线是一样的。中从左上走到某个点,或从某个点走到右下的方案数即可,显然可以。把性质一推广到模意义下,副对角线也推广到模意义下,那么。方便起见,我们可以把所有循环节的障碍重叠起来,设前。,那么左式一定会比比右式在p的指数上少,所以。原创 2022-12-28 22:15:38 · 839 阅读 · 5 评论 -
类欧几里得算法学习笔记
新技巧get原创 2022-07-07 10:52:59 · 322 阅读 · 0 评论 -
Min25筛法学习小记
问题引入已知积性函数f(x)f(x)f(x)要求其前nnn项和(n≤1010n\leq 10^{10}n≤1010)其中对于所有质数ppp满足f(p)=a0+a1p+a2p2……f(p)=a_0+a_1p+a_2p^2……f(p)=a0+a1p+a2p2……也就是可以表示成一个低阶多项式且f(pk)f(p^k)f(pk)可以快速计算I定义lst(x)lst(x)lst(x)表示xxx的最小质因子,pkp_kpk表示第kkk个质数,特别的,p0=1p_0=1p0=1我们把答案拆成质原创 2022-03-01 13:16:28 · 181 阅读 · 0 评论 -
数论模板总结
欧拉筛思路,记录每个数最小的质因子,使每个数只被筛一次void sieve(){ for(int i=1;i<=n;i++) { if(!v[i]) { v[i]=i; phi[i]=i-1; prime[++tot]=i; } for(int j=1;j<=tot;j++) { if(prime[j]>v[i]||i*prime[j]>n) break; v[i*prime[j]]=prime[j]; phi[i*p原创 2022-01-28 16:02:45 · 1061 阅读 · 0 评论 -
gcd与lcm
gcd与lcm题目描述给出某两个整数a和b(a<=b)的最大公约数GCD和最小公倍数LCM,请找出满足的a和b,使得b-a的值最小。输入格式输入数据只有一行,包括两个整数GCD和LCM。输入保证至少存在一组解。输出格式输出包含一个整数,为最小的b-a的值。样例数据input6 36output6数据规模与约定保证1≤a,b≤1e91≤a,b≤1e9。算法一因为设lcm(a,b)=n,gcd(a,b)=m,则a*b=nm所以a,原创 2021-02-27 16:27:24 · 480 阅读 · 0 评论 -
CF1152C Neko does Maths
题目传送门CF1152C Neko does Maths题目描述Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.Neko has two integersaandb. His goal is to find a non-negative integerksuch that the least commo...原创 2021-02-27 16:56:05 · 234 阅读 · 0 评论 -
Prime Distance
题目传送门DescriptionThe branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the question of primality. A prime number is a number that原创 2021-02-28 11:08:40 · 194 阅读 · 0 评论