
数论
菜圾
Hi, it's your Accepted !
展开
-
HDU 6069 - Counting Divisors - (素数筛答案)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6069参考:https://blog.youkuaiyun.com/ctsas/article/details/76640313 https://blog.youkuaiyun.com/dDarkdawn/article/details/76775232题意:首先表示的约数的个数,每组样例给出让求: ...原创 2018-11-16 00:02:16 · 314 阅读 · 0 评论 -
POJ - 3286 - How many 0's? - (统计0的个数)
题目链接:http://poj.org/problem?id=3286题意:给出[a,b],统计这个闭区间中的所有数中包含多少个0。解析:整体思路就是我们用函数solve(n)求出[0,n]中包含0的总个数,答案就是solve(b)-solve(a-1);具体solve函数做法就是对于n的每一位,判断该位为0方案数(该位为0,其余位任意,但是整体的值要小于等于n),统计完所有位原创 2018-02-06 16:32:44 · 270 阅读 · 0 评论 -
poj-1006-Biorhythms-(中国剩余定理)
DescriptionSome people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and the原创 2017-11-09 20:14:44 · 327 阅读 · 0 评论 -
POJ - 3101 - Astronomy - (JAVA大数,分数的最小公倍数)
AC链接:http://poj.org/problem?id=3101原博客:http://blog.youkuaiyun.com/huayunhualuo/article/details/51055611感觉应该记录一下的题目。题意:已知n个行星和每一个行星的周期Ti,求所有行星共线的最短的周期。分析:每一个行星的角速度为vi=2πTi,选择行星0为参考点(所有行星均以其为参考点转载 2018-02-02 16:13:42 · 258 阅读 · 0 评论 -
2018年1月23日训练笔记
今天看的比较乱,上午看了会母函数的题,其余时间在看《初等数论》和《数学一本通》,前两天比赛做到图论的题目然后去看自己之前博客里图论的内容才发现那些博客写的很随便,所以回顾起来图论来很不方便,当然也是因为图论大多是在之前按书上学的,东西多记在了书上,但也是个问题吧,以后要更认真的做总结、写题解,之前很多题解确实是觉得题目比较简单就没细写,还是为了以后看起来方便吧,要写清楚。 下面是《初等数原创 2018-01-23 22:05:39 · 388 阅读 · 0 评论 -
2017年11月26日训练笔记
昨天数论20点关闭,我一直没看进度条还以为还是今天晚上关,所以做的少了一点,心里还是怪不舒服,今天看了看数论的书,看了几个博客和题目,上个数论的总结也有更新。这里也另外补充一些。这组专题应用比较多的有:快速幂,解线性同余方程,分解定理。解线性同余方程,即不互质的中国剩余定理,这个知识点看了很久才明白些,应用还是比较多的, 题目:hdu - 1788 - Ch原创 2017-11-26 22:23:33 · 340 阅读 · 0 评论 -
HDU - 1452 - Happy 2004 - (因子和,极性函数,同余逆元)
转自:http://www.cnblogs.com/372465774y/archive/2012/10/22/2733977.htmlHappy 2004Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 673 Ac转载 2017-11-26 17:28:08 · 250 阅读 · 0 评论 -
poj - 1284 - Primitive Roots - (欧拉函数求原根)
We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive...原创 2017-11-15 12:52:37 · 314 阅读 · 0 评论 -
HDU - 1573 - X问题 - (解线性同余方程)
求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod a[i] = b[i], … (0 < a[i] <= 10)。Input输入数据的第一行为一个正整数T,表示有T组测试数据。每组测试数据的第一行为两个正整数N,M (0 < N <= 1000,000,000 , 0 < M <= 10),表示X小于等于N,数组a和b中各有M个元素。接下来两行,每行各有M个正整数,分别为a和b中的元原创 2017-11-25 22:19:44 · 298 阅读 · 0 评论 -
POJ - 1845 - Sumdiv-(数论,唯一分解定理,约数和公式,用递归二分求等比数列,快速幂)
Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).InputThe only line contains the two natural原创 2017-11-25 20:16:54 · 238 阅读 · 0 评论 -
POJ-1811-Prime Test -(Miller_Rabin算法判断大素数, pollard_rho算法分解质因数)
题目链接:http://poj.org/problem?id=1811题意:给出一个n判断是否为素数,不是的话找出最小质因子。博客:http://blog.youkuaiyun.com/cqbztsy/article/details/47190325https://www.cnblogs.com/kuangbin/archive/2012/08/19/2646404.htmlhttp:转载 2018-02-08 16:56:35 · 205 阅读 · 0 评论 -
POJ - 2689 - Prime Distance - (区间大数筛素数)
AC链接:http://poj.org/problem?id=2689参考:http://blog.youkuaiyun.com/sr_19930829/article/details/41041673关于的筛素数的题目,很不错很典型的题目,由于给出区间是大数的区间我们无法直接筛出其中的素数,但是我们可以利用筛素数的思想,用我们先筛出的一部分小的素数再去筛大的素数,又有sqrt(n)以内的素数能筛出n原创 2018-02-03 11:18:19 · 323 阅读 · 0 评论 -
2017年11月12题训练日记
发现博客10点以后提交不上,数论一会就结束 了,下面说一下部分知识点:快速幂: int pow_mod(int n,int k,int m) //快速幂求n^k余m的结果{ int res=1; n=n%mod; while(k>0) { if(k&1) res...原创 2017-11-12 21:26:01 · 308 阅读 · 0 评论 -
Codeforces Round #520 (Div. 2) - B. Math - (分解质因子)
题目链接:http://codeforces.com/contest/1062/problem/B题意:给出n,有两种操作:令n=sqrt(n); 令n=n*x;这里x是任意正整数。问最少经过多少次操作可以使得n达到一个可以达到的最小值。输出最小值和最小操作次数。解析:先将n分解质因子,假设n=p1^a1*p2^a2*...*pk^ak。观察操作1和操作2,发现n能达到的最小...原创 2018-11-15 15:56:01 · 197 阅读 · 0 评论 -
HDU 6265 - 2017 China Collegiate Programming Contest, Hangzhou - B.Master of Phi -(欧拉函数,公式化简)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6265题意:已知欧拉函数为φ(n),有公式如下:其中p是n的所有互不相同的素因子。然后给出n,求如下函数:其中n是以分解质因子的形式给出,即对于n=p1^q1*p2^q2...*pm^qm,题目先给出m,再接着m行每行给出pi,qi。解析:对于给出的n,d的每个因子,将其带入公式...原创 2018-10-18 00:24:26 · 259 阅读 · 2 评论 -
HDU5974 - The 2016 ACM-ICPC Asia Dalian Regional Contest - D - A Simple Math Problem - (数论LCM,dfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5974题意:给出a和b,让找到X和Y满足:X+Y=a; LCM(X,Y)=b;LCM为最小公倍数,(1≤a≤2*10^4),(1≤b≤10^9),注意:测试样例很多。解析:首先考虑lcm的性质,假设有等式lcm(a,b)=x; 将x分解质因数得:x=p1^num1*p2^num2...原创 2018-10-03 21:50:45 · 206 阅读 · 0 评论 -
POJ - 1601 - 青蛙的约会 - (扩展欧几里得解同余方程)
AC链接:http://poj.org/problem?id=1061参考:http://blog.youkuaiyun.com/loi_dqs/article/details/49488851http://blog.renren.com/share/341541251/14518239244/0解析:线性同余方程同余方程即:ax≡b(mod m),a、b、m都是整数,求解原创 2018-02-05 17:23:42 · 307 阅读 · 0 评论 -
POJ2154(Pólya定理与欧拉函数优化)
不错的Polya题目,有两篇博客给了两个不同的思路,但最终公式都相同代码也相同 题意:给出两个整数n和p,代表n个珠子,n种颜色,要求不同的项链数,翻转置换不考虑。结果模p.题解: 基本知识:共有n种置换(都是旋转置换),每种置换循环节的个数为gcd(n , i) , 对应循环节长度为L=n / gcd(n , i)(旋转置换中的所有循环节的长度相同)其中i为转的位置数。 普...转载 2018-01-30 10:33:25 · 305 阅读 · 0 评论 -
POJ 1681 Painter's Problem,POJ 1222 EXTENDED LIGHTS OUT (高斯消元之异或方程组),高斯消元模板
两个异或方程组的题目,都比较经典,贴上代码当模板,代码来自他人博客POJ 1222题目大意:给你一个5*6的格子,每个格子中有灯(亮着1,暗着0),每次你可以把一个暗的点亮(或者亮的熄灭)然后它上下左右的灯也会跟着变化。最后让你把所有的灯熄灭,问你应该改变哪些灯。/* Poj 1222 Author: Robert_Yuan Memory: 364K原创 2018-01-29 16:29:32 · 294 阅读 · 0 评论 -
POJ - 2154 Color - (Ploya定理,欧拉函数,1~n的gcd(n,i)之和)
DescriptionBeads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of the necklace can be produced. You ...原创 2018-01-08 22:04:05 · 599 阅读 · 0 评论 -
hdu - 3579 - Hello Kiki - (不互质的中国剩余定理)
One 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 counted coins ba原创 2017-11-19 22:15:02 · 430 阅读 · 0 评论 -
hdu - 1788 - Chinese remainder theorem again-(gcd,不互质的中国剩余定理)
我知道部分同学最近在看中国剩余定理,就这个定理本身,还是比较简单的: 假设m1,m2,…,mk两两互素,则下面同余方程组: x≡a1(mod m1) x≡a2(mod m2) … x≡ak(mod mk) 在0记Mi=M/mi(1ei≡0(mod mj),j!=i ei≡1(mod mj),j=i 很显然,e1a1+e2a2+…+ekak就是方程组的一个解,原创 2017-11-19 19:34:14 · 363 阅读 · 0 评论 -
数学公式
转自:http://blog.youkuaiyun.com/hanhai768/article/details/38018991(1) 整数的唯一分解定理: 任意正整数都有且只有一种方式写出其素因子的乘积表达式。 A=(p1^k1)*(p2^k2)*(p3^k3)*....*(pn^kn) 其中pi均为素数(2) 约数和公式:转载 2017-11-25 20:15:07 · 285 阅读 · 0 评论 -
hdu - 3123 - GCC - (阶乘求余)
The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages. But it doesn’t contains the math operator “!”. In ma原创 2017-11-25 13:58:35 · 242 阅读 · 0 评论 -
POJ - 1995 - Raising Modulo Numbers - (快速幂)
People are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult mathematical games.原创 2017-11-24 00:19:17 · 196 阅读 · 0 评论 -
UVa - 571 - Jugs -(倒水问题)
参考:https://www.cnblogs.com/devymex/archive/2010/08/04/1792288.htmlTime limit: 3.000 seconds BackgroundIn the movie "Die Hard 3", Bruce Willis and Samuel L. Jackson were confronted with原创 2017-11-11 17:44:06 · 272 阅读 · 0 评论 -
uva-10299-Relatives-(欧拉函数)
Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such t...原创 2017-11-11 17:30:02 · 359 阅读 · 0 评论 -
Uva-10162-Last Digit-(快速幂,规律)
代码:#include#include#include#include#include#include#include#include#includeusing namespace std;typedef long long ll;#define M 105int len;char str[110];int ans[M];int powmod(int n,int原创 2017-11-09 21:40:50 · 203 阅读 · 0 评论 -
中国剩余定理(详解)
中国剩余定理中国剩余定理可以描述为:若某数x分别被d1、、…、dn除得的余数为r1、r2、…、rn,则可表示为下式:x=R1r1+R2r2+…+Rnrn+RD其中R1是d2、d3、…、dn的公倍数,而且被d1除,余数为1;(称为R1相对于d1的数论倒数)R1 、R2 、… 、Rn是d1、d2、…、dn-1的公倍数,而且被dn除,余数为1;D转载 2017-11-09 20:27:19 · 2771 阅读 · 0 评论 -
UVa-10139 Factovisors -(阶乘的整除)
计算数 m 和数 2 ~n 的 GCD,若 GCD > 1,则 m /= GCD,若最后 m 不为 1 则表明 m 不能整除 n!,代码:#include#include#include#include#include#include#include#include#includeusing namespace std;#define M 1000005typed原创 2017-11-09 09:57:03 · 339 阅读 · 0 评论 -
UVA-11029-Leading and Trailing-(快速幂,log10函数求大数首末数)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1970part from the novice programmers, all others know that you can’t exactly rep原创 2017-10-29 23:56:45 · 390 阅读 · 0 评论 -
POJ-1305-Fermat vs. Pythagoras-(本原勾股数)
DescriptionComputer generated and assisted proofs and verification occupy a small niche in the realm of Computer Science. The first proof of the four-color problem was completed with the assistanc原创 2017-10-29 20:35:24 · 329 阅读 · 0 评论 -
uva 10994 - Simple Addition
#include#include#include#include#include#include#include#include#includeusing namespace std;#define M 1000005typedef long long ll;int p,q;ll ans;ll f(ll n){ if(n==0) retur原创 2017-11-06 23:20:43 · 289 阅读 · 0 评论 -
UVA 10539 Almost Prime Numbers( 素数因子)
Almost prime numbers are the non-prime numbers which are divisible by only a single prime number. In this problem your job is to write a program which finds out the number of almost prime numbers with原创 2017-11-06 23:13:21 · 299 阅读 · 0 评论 -
UVa - 10616 - Divisible Group Sums(dp)
Given a list of N numbers you will be allowed to choose any M of them. So you can choose in NCM ways. You will have to determine how many of these chosen groups have a sum, which is divisible by D.原创 2017-11-11 20:42:11 · 261 阅读 · 0 评论 -
UVA - 10820 - Send a Table -(欧拉函数)
Send a TableInput: Standard InputOutput: Standard Output When participating in programming contests, you sometimes face the following problem: You know how to calcutale the output for th原创 2017-11-11 21:59:25 · 217 阅读 · 0 评论 -
UVa - 10717 - Mint-(4个数的最大公约数)
The Royal Canadian Mint has commissioned a new series of designer coffee tables, with legs that are constructed from stacks of coins. Each table has four legs, each of which uses a different type of原创 2017-11-12 20:03:24 · 250 阅读 · 0 评论 -
poj - 1730 - Perfect Pth Powers - (分解质因数)
We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube if, for some integer b, x = b 3. More generally, x is a perfect pth power if, for some integer b, x =原创 2017-11-23 12:33:06 · 403 阅读 · 0 评论 -
hdu - 2973 - YAPTCHA - (威尔逊定理)
The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-Public-Turing-Test-原创 2017-11-23 10:45:26 · 348 阅读 · 0 评论 -
POJ - 1320 - Street Numbers - (佩尔方程)
A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her dog by leaving her house and randomly turning left or right原创 2017-11-17 00:26:09 · 360 阅读 · 0 评论