![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
protecteyesight
我向往天空的湛蓝和一望无际。保护视力,只为看到更远的天空。
展开
-
FZU 1759 Super A^B mod C (超级快速幂)
Given A,B,C, You should quickly calculate the result of A^B mod C. (1InputThere are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a sing原创 2017-03-20 18:26:23 · 420 阅读 · 0 评论 -
hdu 5050 java高精度GCD
It’s time to fight the local despots and redistribute the land. There is a rectangular piece of land granted from the government, whose length and width are both in binary form. As the mayor, you must原创 2017-07-07 08:51:28 · 296 阅读 · 0 评论 -
hdu 6063 RXD and math (迷之 快速幂)
题中μ(i)函数是多校二里出现过的莫比乌斯反演函数(没弄懂),不过有模板,照着打个表然后瞎暴力一下看看上面式子的结果,发现结果就是直接n的k次幂。发现结果赶紧套了个快速幂的模板,直接WA,难道不是这样???多验证了几个数发现没有错啊.......…T_T后来想了想快速幂模板里底数n原本是int的,我是直接改long long了,这里就是错误的根源……要先把底数取模,不然中间两个lon原创 2017-08-01 19:53:18 · 260 阅读 · 2 评论 -
nefu 84 五指山(扩展ou'ji'li)
五指山Problem:84Time Limit:1000msMemory Limit:65536KDescription西游记中孙吾空大闹天宫,如来佛祖前来降伏他,说道:“我与你打个赌赛;你若有本事,一筋斗打出我这右手掌中,算你赢,再不用动刀兵苦争战,就请玉帝到西方居住,把天宫让你;若不原创 2017-09-07 20:23:54 · 375 阅读 · 0 评论 -
HDU 6128 Inverse of sum(取模+map处理)
传送门1≡1+ajai+1+aiajmodp(1)原创 2017-08-31 11:49:42 · 209 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(西安赛区)网络赛 Trig Function(数据水,暴力+逆元)
题意:求上面那个神奇的函数的x的m次方的系数。参考:点击打开链接提取出本题中用到的信息:数据比较水,算双阶乘的时候把能约掉的约掉,阶乘直接暴力,注意逆元,判断条件写清楚就行了。#include using namespace std;typedef long long LL;const int MOD=998244353;LL jc(LL m)原创 2017-09-16 16:06:52 · 405 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(西安赛区)网络赛 Coin (概率公式+快速幂)
题意:一枚不均匀的硬币,正面向上的概率是q/p,问抛k次之后向上的次数为偶数的概率是多少。输出的概率是整数,是把概率变成分数取模(逆元)得到的。思路:度娘神了,下面的例子正好可以用于本题,把最后的结果化成一个分数的形式就可以快速幂了。#include int MOD=1e9+7;using namespace std;typedef long long LL;原创 2017-09-16 15:57:27 · 278 阅读 · 0 评论 -
Gym - 101503J Numbers Painting(素数分解+思维)
题意:输入一个数N,在1~N中,对于任意两个数A,B,如果A能被B整除,那么A,B,要染上不同的颜色,颜色用不同的数字表示,然而要保证用到的颜色的数量最小,问你怎么排列。分析: 首先想到的是类似于素数筛那样的填数,但是发现思路不对,而且有的数会染重复,那么正确的思路是对1~N的每个数进行素数分解。那么所有的素数都标2,1被1占了,接下来分解后的一个数就可以表示出来它最大的那原创 2017-10-15 16:57:21 · 377 阅读 · 0 评论 -
hdu6069 Counting Divisors(质数分解+技巧)
d(n)里n的取值最大1e12,那么要判断它是不是素数只需计算到sqrt(n),所以打个1e6的素数表,如果它是个合数,就可以用打好的表里的素数进行分解,如果是个素数, 那么它对最后结果的贡献就是k+1。遍历和计算中的技巧:数组开到1e6,从l到r拿0到r-l对应。中间遍历时先遍历素数表,假设现在遍历到prime[i],先找到l~r第一个能整除prime[i]的数a[j],以此原创 2017-08-04 15:21:46 · 1287 阅读 · 2 评论 -
HDU 4059 The Boss on Mars(质数分解+容斥)
题目自行搜索题意:给你一个数n,求小于n并且与n互质的所有数的4次方之和。分析:n的数据量达到1e8,O(n)的复杂度都悬,由此想到因数分解O(sqrt(n))。那么把一个数因数分解之后,是一个 若干质数的若干次幂相乘的形式,那么对这个分解式的每一个质数来说,如果某个小于n的数是某个质因数的倍数的话,那么这个小于n的数就不是答案里出现的数,那么对于分解出的每个质因数都要遍历,只原创 2017-10-07 17:54:21 · 256 阅读 · 0 评论 -
HDU 5512 Pagodas (水题+GCD )
nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 11 to nn. However, only two of them (labelled aa and bb, where 1≤a≠b≤n1≤a≠b≤n)原创 2017-06-15 14:54:25 · 364 阅读 · 0 评论 -
hdu5114 Collision (扩展欧几里德+思维)
Matt is playing a naive computer game with his deeply loved pure girl. The playground is a rectangle with walls around. Two balls are put in different positions inside the rectangle. The balls are原创 2017-06-30 18:55:15 · 340 阅读 · 0 评论 -
ACdream 1084-数论训练B题--寒假安排
B - 寒假安排Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %lluSubmit Status Practice ACdream 1084Description寒假又快要到了,不过对于lzx来说,头疼的事又来了,因为众多的后宫都指望着能和lzx约会呢,lz原创 2016-10-28 18:43:28 · 277 阅读 · 0 评论 -
POJ 2478-数论训练F题 -(水题 )欧拉加打表
F - Farey SequenceTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set原创 2016-10-17 19:26:01 · 263 阅读 · 0 评论 -
HDU 3579-数论训练A题 exgcd加中国剩余定理
DescriptionOne day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running and singing "门前大桥下游过一群鸭,快来快来 数一数,二四六七八". And then the cashier put the c原创 2016-10-17 10:03:46 · 442 阅读 · 0 评论 -
POJ 2478-数论训练D题 费马小定理加快速幂
DescriptionInput2Output2 这道题目意思是给出一个数n,求把它分成1份,2份,3份...n份(分出的都是自然数)总共有多少种方法,数据很大结果对1e9+7取余。刚开始看到这题一脸茫然,后经过学习前人的经验,看出了一些端倪,毕竟是与数学有关的题目原创 2016-10-14 19:15:11 · 702 阅读 · 0 评论 -
HDU 2588 GCD-数论训练C题 欧拉
DescriptionThe greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6. (a,b) can be easi原创 2016-10-17 19:02:51 · 374 阅读 · 0 评论 -
由NEFU 519引发的思考(关于逆元)
兴安黑熊在高中学习数学时,曾经知道这样一个公式:f(n)=1^2+2^2+3^2+.......+n^2,这个公式是可以化简的,化简后的结果是啥它却忘记了,也许刚上大二的你能记得。现在的问题是想要计算f(n)对1007取余的值,你能帮帮他吗?Input输入数据有多组,每组一个数n. (1<=n <=1,000,000,000).原创 2017-05-24 14:30:10 · 272 阅读 · 0 评论 -
HDU-4569 Special equations (利用数学知识巧妙降低复杂度)
Let f(x) = a nx n +...+ a 1x +a 0, in which a i (0 <= i <= n) are all known integers. We call f(x) 0 (mod m) congruence equation. If m is a composite, we can factor m into powers of primes and solve原创 2017-05-31 17:58:55 · 320 阅读 · 0 评论 -
HDU5974 数论+解方程
D - A Simple Math Problem HDU - 5974 Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a原创 2017-06-08 21:19:04 · 325 阅读 · 0 评论 -
HDU 5976 贪心+逆元
F - Detachment HDU - 5976 In a highly developed alien society, the habitats are almost infinite dimensional space. In the history of this planet,there is an old puzzle. You have a line原创 2017-06-08 21:25:25 · 308 阅读 · 0 评论 -
NEFU 163 Co-prime(质数分解+容斥)
DescriptionGiven a number N, you are asked to count the number of integers between A and Binclusive which are relatively prime to N.Two integers are said to be co-prime or relatively prime if原创 2017-10-11 17:56:28 · 339 阅读 · 0 评论