数论
简单数论
邵光亮
要为自己喜欢的事情不留余力
展开
-
求114514^n的因子和mod 19260817
求 114514n114514^n114514n 的因子和 mod19260817mod 19260817mod19260817,192608171926081719260817 是质数,114514114514114514 的质因子是 2,31,18472,31,18472,31,1847。2,12 ,12,131,131 ,131,11847,11847 ,11847,1114514114514114514 的因子和为 s(2)∗s(31)∗s(1847)=3∗32∗1845=177120s(原创 2020-06-04 17:06:45 · 144607 阅读 · 5 评论 -
Codeforces 1316 C. Primitive Primes
题意:给出了两个多项式的系数,求两个多项式相乘后问系数不能被p整除的幂的值高斯引理:两个本原多项式的乘积仍为本原多项式.本原多项式:满足所有系数的最大公因数为 111 的多项式用 aia_iai表示第一个多项式的 iii 次方的系数 bib_ibi表示第二个多项式的 iii 次方的系数cic_ici表示相乘后 iii 次方的乘积后的系数ci=a∗bi+a1∗bi−1+…+...原创 2020-03-05 10:32:00 · 142067 阅读 · 3 评论 -
数论基础
整除理论:唯一分解定理,对于一个合数,唯一存在一种质数分解。应用在算法复杂度估计,因子个数的计算。素因子个数为 O(logn)O(log n)O(logn) 级别因子个数为 O(n3)O(\sqrt[3]{n})O(3n) ~ O(n)O(\sqrt{n})O(n) 级别如果一个数能被一堆数整除,那么这个数被称为这些数的公约数。裴蜀定理对于 a,ba,ba,b,存在 x...原创 2020-03-01 17:31:27 · 148847 阅读 · 1 评论 -
2020 CCPC Wannafly Winter Camp Day2 C 纳新一百的石子游戏(博弈论)
题意:有 nnn 堆石子,第 iii 堆石子有 aia_iai 个。两个人可以选择某些石子堆玩游戏:两人交替进行操作,轮到某个人时需要选择一堆非空的石子并拿走一些。若不存在一堆非空的石子,则轮到的人输。对 ∀i∈[1,N]\forall i\in\left[1,N\right]∀i∈[1,N],求用前 iii 堆石子玩游戏时先手取石子有多少种取法必胜。一个简单结论:用前 iii ...原创 2020-02-22 16:14:13 · 361 阅读 · 1 评论 -
2020 CCPC Wannafly Winter Camp Day2 A 托米的字符串(期望)
题意:给定一个只含小写字母的字符串 sss。求随机取一个子串元音和半元音字母 (a,e,i,o,u,y)\left(a,e,i,o,u,y\right)(a,e,i,o,u,y) 占比的期望。记 aia_iai表示 sss 的前 iii 个字母中元音和半元音字母个数。记 fif_ifi 表示所有长度为 iii 的子串中元音和半元音字母出现次数之和。显然有 fi=fi−1+an−i+1...原创 2020-02-22 11:23:06 · 276 阅读 · 0 评论 -
2020 CCPC Wannafly Winter Camp Day1 H 最大公约数(数论)
题目描述有三个人,A,B,CA,B,CA,B,C ,其中 A{A}A 和 BBB 共享了一个神秘的数字 kkk,已知 1≤k≤n1\leq k \leq n1≤k≤n 。现在 AAA和 CCC 说:“kkk 的值等于 xxx”。CCC 不太信任 AAA,于是想向 BBB 确认一下 kkk 是否真的等于 xxx。BBB 虽然不想直接把 kkk 的值告诉 CCC,但是 BBB 允许 CCC 给出...原创 2020-02-21 17:22:55 · 245 阅读 · 0 评论 -
UVA 10236 The Fibonacci Primes (斐波那契素数)
Description:The Fibonacci number sequence is 1,1,2,3,5,8,131, 1, 2, 3, 5, 8, 131,1,2,3,5,8,13 and so on. You can see that except the first two numbers the others are summation of their previous two n...原创 2020-02-15 16:50:35 · 288 阅读 · 1 评论 -
UVA 11256 Repetitive Multiple (整数循环节)
Description:An integer is said to be repetitive if it can be written as a concatenation of several copies (at least two) of another non-zero-leading integer. For example, 11, 123123, 454545 are all r...原创 2020-02-12 15:35:46 · 205 阅读 · 1 评论 -
UVA 701 The Archeologists' Dilemma
Description:An archeologist seeking proof of the presence of extraterrestrials in the Earth’s past, stumbles upon a partially destroyed wall containing strange chains of numbers. The left-hand part o...原创 2020-02-10 17:30:35 · 245 阅读 · 0 评论 -
UVA 10061 进制问题
Description:Given a decimal integer number you will have to find out how many trailing zeros will be there in itsfactorial in a given number system and also you will have to find how many digits wil...原创 2020-02-08 16:03:46 · 209 阅读 · 0 评论 -
POJ 2689 (素数区间筛法)
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 questio...原创 2020-02-08 11:43:59 · 339 阅读 · 0 评论 -
UVA 294 - Divisors (因子个数)
Description:Mathematicians love all sorts of odd properties of numbers. For instance, they consider 945945945 to be an interesting number, since it is the first odd number for which the sum of its di...原创 2020-02-06 17:11:01 · 227 阅读 · 0 评论 -
POJ1730_Perfect Pth Powers (开方,新知识)
DescriptionWe say that xxx is a perfect square if, for some integer b,x=b2b, x = b^2b,x=b2. Similarly, xxx is a perfect cube if, for some integer b,x=b3.b, x = b^3.b,x=b3. More generally, xxx is a pe...原创 2020-02-05 22:56:30 · 282 阅读 · 0 评论 -
UVA 11728 - Alternate Task (因子和)
Description:Little Hasan loves to play number games with his friends. One day they were playing a game whereone of them will speak out a positive number and the others have to tell the sum of its fa...原创 2020-02-05 18:41:23 · 185 阅读 · 1 评论 -
CCPC-Wannafly Camp Day7 H 游戏(期望)
Description:有1到n这些数字各一个。你用这些数字进行若干轮游戏。 对于每一轮,如果剩下的数字个数超过1个,那么就等概率随机选择两个剩下的数字删去。如果这两个数字互质,得一分。 重复以上操作直到没数字可以删除为止。请问最后期望得多少分?输入格式一行一个整数n (1≤n≤5000)。输出格式输出一个最简约数ba 表示答案。输入样例24输出样例1/15...原创 2020-02-04 18:28:00 · 351 阅读 · 0 评论 -
CodeForces 71 C.Round Table Knights
Description:There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.Merlin, the wizard predicted to King Arthur that th...原创 2020-02-04 12:46:08 · 474 阅读 · 0 评论 -
codeforces 633B B. A Trivial Problem
Description:Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n e...原创 2020-02-04 11:20:42 · 250 阅读 · 0 评论 -
CodeForces 75C - Modified GCD(二分)
Description:Well, here is another math class task. In mathematics, GCDGCDGCD is the greatest common divisor, and it’s an easy task to calculate the GCDGCDGCD between two positive integers.A common d...原创 2020-02-04 10:35:58 · 342 阅读 · 0 评论 -
HDU1098 Ignatius's puzzle (数学归纳法)
Description:Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that: f(x)=5∗x13+13∗x5+k∗a∗xf(x)=5*x^{13}+13*x^5+k*a*xf(x)=5∗x1...原创 2020-01-27 19:09:48 · 361 阅读 · 0 评论 -
HDU 5223 GCD
Description:In mathematics, the greatest common divisor (gcdgcdgcd) of two or more integers, when at least one of them is not zero, is the largest positive integer that divides the numbers without a ...原创 2020-01-24 11:29:13 · 218 阅读 · 0 评论 -
HDU 6441 Find Integer (费马大定理)
Description:people in USSS love math very much, and there is a famous math problemgive you two integers n,a,you are required to find 222 integers b,cb,cb,c such that an+bn=cna_{n}+b_{n}=c_{n}an+bn...原创 2020-01-22 17:18:35 · 162 阅读 · 0 评论 -
CodeForces 1285 C Fadi and LCM (GCD)
Description:Today, Osama gave Fadi an integer XXX, and Fadi was wondering about the minimum possible value of max(a,b)max(a,b)max(a,b) such that LCM(a,b)LCM(a,b)LCM(a,b) equals XXX. Both aaa and bbb ...原创 2020-01-16 11:12:17 · 515 阅读 · 0 评论 -
HDU5478——Can you find it(化简)
Description:Given a prime number C(1≤C≤2×105)C(1≤C≤2×10^5)C(1≤C≤2×105), and three integers k1,b1,k2(1≤k1,k2,b1≤109)k_{1}, b_{1}, k_{2} (1≤k1,k2,b1≤10^9)k1,b1,k2(1≤k1,k2,b1≤109). Please find all pa...原创 2020-01-13 18:43:43 · 273 阅读 · 0 评论 -
HDU 2879 HeHe (积性函数+素数)
Description:In the equation X2≡X(modN)X^2≡X(mod N)X2≡X(modN) where x∈[0,N−1]x∈[0,N-1]x∈[0,N−1], we define He[N] as the number of solutions.And furthermore, define HeHe[N]=He[1]∗……∗He[N]HeHe[N]=He[1]...原创 2020-01-13 09:21:46 · 191 阅读 · 0 评论 -
HDU2620 Ice Rain(数论分块)
Description:\quadIce Rain------I was waiting for a girl, or waiting for been addicted to the bitter sea. Love for irrigation in silence. No one considered whether the flowers came out or wither. Love...原创 2019-12-21 16:50:03 · 208 阅读 · 0 评论 -
HDU 2619 - Love you Ten thousand years (原根)
Description:Love you Ten thousand years------Earth’s rotation is a day that is the representative of a day I love you. True love, there is no limit and no defects. Earth’s revolution once a year, it ...原创 2019-12-20 22:03:07 · 297 阅读 · 0 评论 -
BeijingHDU - 1852 Beijing Beijing (不互质求逆元)
Description:As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a little special somehow. You are looking forward to it, too, aren’t you? Unfortunately ther...原创 2019-12-19 18:30:23 · 631 阅读 · 0 评论 -
HDU1792 A New Change Problem 推理+证明详解(关于数论中的互质数的最大不能组合数 )
Description:Now given two kinds of coins AAA and BBB,which satisfy that GCD(A,B)=1GCD(A,B)=1GCD(A,B)=1.Here you can assume that there are enough coins for both kinds.Please calculate the maximal valu...原创 2019-12-19 16:31:38 · 402 阅读 · 0 评论 -
GCD性质
Description:To think of a beautiful problem description is so hard for me that let’s just drop them off. ????Given four integers a,m,n,ka,m,n,ka,m,n,k,and S=gcd(am−1,an−1)%kS = gcd(a^{m-1},a^{n-1})\%kS...原创 2019-12-18 22:48:33 · 691 阅读 · 0 评论 -
威尔逊定理
定义:\quad \quad \quad\quad ppp为质⟺\Longleftrightarrow⟺(p−1)!≡−1(modp)(p−1)!≡−1(modp)(p−1)!≡−1(modp)或者可以写成:\quad \quad \quad\quad ppp为质数⟺\Longleftrightarrow⟺(p−1)!≡p−1(modp)(p−1)!≡p−1(modp)(p−1)!≡p−...原创 2019-12-03 17:36:31 · 231 阅读 · 0 评论 -
Codeforces 1263C Everyone is a Winner(枚举or数论分块)
Description\quadOn the well-known testing system MathForces, a draw of n rating units is arranged. The rating will be distributed according to the following algorithm: if kkk participants take part i...原创 2019-11-30 11:16:59 · 598 阅读 · 0 评论 -
Codeforces 1260C Infinite Fence(扩展欧几里得)
Description:\quadYou are a rebel leader and you are planning to start aaa revolution in your country. But the evil Government found out about your plans and set your punishment in the form of correct...原创 2019-11-28 16:26:52 · 859 阅读 · 0 评论 -
Codeforces 1152C Neko does Maths(数论)
lcm=n∗m/gcd\textbf{lcm=n∗m/gcd}lcm=n∗m/gcdn+k和m+k的lcm要变小,那么加k之后肯定有更大的最大公因数,那么假设他们加上k之后拥有了公因数z满足公式 (n+k) mod z ==(m+k) mod z\textbf{\textit{(n+k) mod z ==(m+k) mod z}}(n+k...原创 2019-11-19 20:28:47 · 225 阅读 · 0 评论 -
HDU6198 number number number(打表 矩阵快速幂)
题意就是找到用K个斐波那契数组不成的最小的数字是谁。先打表找规律1 4 2 12 3 33 4 88 5 232 6 609 可以发现递推规律:F[n]=4*(F[n-1]-F[n-2])+F[n-3]如果直接递推打表1e9是打不出来的,这时候就用矩阵快速幂来做。AC代码:#include<cstdio&...原创 2019-10-24 19:06:10 · 243 阅读 · 0 评论 -
codeforces 595 C2. Good Numbers (hard version)
给出Q组查询,每组给出一个N找到一个>=n的m,m可以分解成不同的3的幂次相加。可以看题意解释,就是转化为3^0,3^1,...,3^m,每个只能出现最多一次,但是可以不同组合,输出符合条件最小的M。其实就是把N转化成三进制,然后看每一位,如果>=2,就将当前位变成0,下一位+1,然后找到最高位>=2的,把他前面的位都变成0,这样可以保证找到的最小的。AC代码:...原创 2019-10-23 16:48:30 · 453 阅读 · 0 评论 -
2018南京Gym - 101981J - Prime Game(计数)
第一个元素的素因子2:它能贡献的区间有[1,1],[1,2],……,[1,10] 10个区间第一个元素的素因子3:它能贡献的区间有[1,1],[1,2],……,[1,10] 10个区间当前sum = 10+10第二个元素的素因子7:它能贡献的区间有[1,2],[1,3],……,[1,10] 9个区间它能贡献的区间有[2,2],[2,3],……,[2,10] 9个区间当前su...原创 2019-10-22 19:20:46 · 250 阅读 · 0 评论 -
Gym - 101981G The 2018 ICPC Asia Nanjing Regional Contest G.Pyramid 找规律
数一个n阶三角形中,有多少个全等三角形,n<=1e9拿到题想找规律,手画开始一直数漏....,最后还是打了个表(打表就是随便定个点为(0,0),然后(2,0),(4,0),(6,0),(1,sqrt(3)),(3,sqrt(3)),(5,sqrt(3)),(2,2*sqrt(3))...)这样然后枚举三点算打出来1,5,15,70,126,210,330,495,7...原创 2019-10-22 19:03:49 · 337 阅读 · 0 评论 -
codeforces 1047C. Enlarge GCD(数学)
题意:给出n个数,求出最少删除几个数可以扩大最大公因子。AC代码:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<set>#include<map>#include<vect...原创 2019-05-23 17:47:15 · 788 阅读 · 0 评论