【HDU】2866:Special Prime【数论】】的更多相关文章

Special Prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 738    Accepted Submission(s): 390 Problem Description Give you a prime number p, if you could find some natural number (0 is not in…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=2866 题意:在区间[2,L]内,有多少个素数p,满足方程有解. 分析: 原方程变为: n^(b-1) * (p+n) = m ^ b. 一开始,我们会想,这个方程在什么时候是有解的呢?? 肯定当左边式子能够凑成形如  X^b 这样的式子对不对?? 那么,也就是说,一定不存正整数k使得n = k*p. 即当且仅当gcd(n^(b-1),(p+n)) = 1时方程有解. 为什么?? 我们利用反证法可以进…
HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points which are in three-dimensional space(without repetition). Please find out how many distinct Special Tetrahedron among them. A tetrahedron is ca…
Problem hdu-2866 题意:求区间\([2,L]\)有多少素数\(p\)满足\(n^3+pn^2=m^3\),其中\(n,m\)属于任意整数 Solution 原式等价于\(n^2(p+n)=m^3\) 可证当\(p|\gcd(n^2,n+p)\)时,无解,因为当\(n=k\cdot p\)时 \(k^2p^3+k^3p^3=m^3\) \(m=p\sqrt [3]{k^2+k^3}\)可证无整数解,对于这一点,证明如下 \(k^2+k^3=k^2(1+k)\) 假如\(1+k\)为…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
Least Common Multiple (HDU - 1019) [简单数论][LCM][欧几里得辗转相除法] 标签: 入门讲座题解 数论 题目描述 The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7…
七夕节 (HDU - 1215) [简单数论][找因数] 标签: 入门讲座题解 数论 题目描述 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" 人们纷纷来到告示前,都想知道谁才是自己的另一半.告示如下: 数字N的因子就是所有比N小又能被N整除的所有正整数,如12的因子有1,2,3,4,6. 你想知道你的另一半吗? Input 输入数据的第一行是一个数字T(1<=T<=500000)…
Special Prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 415    Accepted Submission(s): 220 Problem Description Give you a prime number p, if you could find some natural number (0 is not in…
Problem Description Let f(x) = anxn +...+ a1x +a0, in which ai (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 every such single equation after wh…
Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4569 Description 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…
hdu5901题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5901 code vs 3223题目链接:http://codevs.cn/problem/3223/ 思路:主要是用了一个Meisell-Lehmer算法模板,复杂度O(n^(2/3)).讲道理,我不是很懂(瞎说什么大实话....),下面输出请自己改 #include<bits/stdc++.h> using namespace std; typedef long long LL;…
H - Visible Trees Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2841 Description There are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) poi…
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points which are in three-dimensional space(without repetition). Please find out how many distinct Special Tetrahedron among them. A tetrahedron is called Sp…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6169 题意:给了区间L,R,求[L,R]区间所有满足其最小质数因子为k的数的和. 解法: 我看了这篇blog.http://blog.csdn.net/wubaizhe/article/details/77484454#cpp 先放在这里,明天来补推导过程. #include <bits/stdc++.h> using namespace std; typedef long long LL; co…
题目http://acm.hdu.edu.cn/showproblem.php?pid=1879 复习一下最小生成树的两个基本算法. 由于存在道路是否已修建的问题,如果已修建,那么该条道路的成本即为0. 首先复习一下kruskal,它的思路主要是既然有那么多边,那么多权值(这里即为成本),要求全连通后最小的权值,那么就将权值排序,先从最小的权值看起, 将该权值的对应的两点用并查集合并到一个集合里,然后依次按照权值从小到大的顺序比较下去,如果该权值对应的两点的祖先结点相同,证明这两点已经 连通,如…
Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points which are in three-dimensional space(without repetition). Please find out how many distinct Special Tetrahedron among them. A tetrahedron is called Sp…
找范围内回文素数,最大到1e8,我就是要枚举回文串,再判素数,然后因为这种弱智思路死磕了很久题目. /** @Date : 2017-09-08 15:24:43 * @FileName: HDU 1431 思维 找回文素数.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <bits/std…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5382 题意:函数lcm(a,b):求两整数a,b的最小公倍数:函数gcd(a,b):求两整数a,b的最大公约数.函数[exp],其中exp是一个逻辑表达式.如果逻辑表达式exp是真,那么函数[exp]的值是1,否则函数[exp]的值是0.例如:[1+2>=3] = 1 ,[1+2>=4] = 0. 求S(n)的值. #include <bits/stdc++.h> using name…
Special Fish Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2367    Accepted Submission(s): 878 Problem Description There is a kind of special fish in the East Lake where is closed to campus o…
Problem Description Mr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Greatest Common Divisor Query (RGCDQ). What’s RGCDQ? Please let me explain it to you…
http://acm.hdu.edu.cn/showproblem.php?pid=4036 一开始以为需要用斜抛,结果发现只需要用能量守恒定律?+与最大速度的坏土豆速度保持一致 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int maxn=1e3+3; int n,m; double w; doub…
参考链接http://blog.csdn.net/acm_cxlove/article/details/8264290http://blog.csdn.net/w00w12l/article/details/8212782 题意: 首先定义了一种叫做Reverse Prime的数:是一个7位数,倒置后是一个<=10^6的素数(如1000070) 然后要把所有的Reverse Prime求出来,排好序. 然后题目有2种操作: q x :求编号0到编号x的Reverse Prime的质因数个数的和…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5839 在一个三维坐标,给你n个点,问你有多少个四面体(4个点,6条边) 且满足至少四边相等 其余两边不相邻. 暴力4重循环,但是在第3重循环的时候需要判断是否是等腰三角形,这便是一个剪枝.在第4重循环的时候判断4点是否共面 (叉乘), 5或者6边相等就+1,4边相等就判断另外两边是否相交就行了. 赛后过的,觉得自己还是太菜了. //#pragma comment(linker, "/STACK:10…
http://acm.hdu.edu.cn/showproblem.php? pid=1124 題目好長好長,好可怕,看完腎都萎了,以後肯定活不長.我可不能死在這種小事上,小灰灰我勵志死在少女的超短裙下~~~哈哈,所以我就猥瑣的叫 旁邊的小師妹幫我翻譯了,我是不是非常禽獸,嘻嘻~~~ 題目大意呢,就是給一個數,要你求出它的階乘的得到的結果後面有幾個0. 解析: 一看就是簡單數論啦.跟數因子有關.最小素因子并且相乘能得到10的(就是後面有0的)就是2*5啦.因為一個數的階乘2的因子明顯比5的因子要…
继续数论.. Problem Description WhereIsHeroFrom:            Zty,what are you doing ? Zty:                                    Iwant to calculate N!...... WhereIsHeroFrom:            Soeasy! How big N is ? Zty:                                    1<=N <=100…
Problem Description Everybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc. Specially, LPF(1) = 0. Inpu…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1852 这道题和HDU1452类似. 题意:给你一个n.k,让你求2008^n所有因子的和(包括1和本身)%k,得到m,然后输出2008^m%k. 题解:看我HDU1452题,这里有一点需要注意的是: s=(2^(3n+1)-1)(251^(n+1)-1)/250 因为gcd(250,k)不一定等于1,所以不能用求逆元的方法求解, 而k很小,所以我们可以将k乘以250,然后在进行,最后结果一定可以整…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4569 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有f(x+p)%p=0. 所以我们可以开始从0到p枚举x,当f(x)%p=0,然后再从x到p*p枚举,不过每次都是+p,找到了输出即可,没有的话No solution! AC代码: #include <iostream> #includ…
题目链接:hdu 4861 Couple doubi 题目大意:两个人进行游戏,桌上有k个球,第i个球的值为1i+2i+⋯+(p−1)i%p,两个人轮流取,假设DouBiNan的值大的话就输出YES,否则输出NO. 解题思路: 首先是DouBiNan先取,所以肯定优先选取剩余中值最大的,于是不存在说DouBiNan值小的情况,仅仅有大于和小于. 然后,对于val(i)=1i+2i+⋯+(p−1)i%p来说,仅仅有当i=ϕ(p)=p−1(p为素数)时,val(i)=p−1,其它情况下val(i)=…
寻找素数对 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 8771    Accepted Submission(s): 4395 Problem Description 哥德巴赫猜想大家都知道一点吧.我们如今不是想证明这个结论,而是想在程序语言内部可以表示的数集中,随意取出一个偶数,来寻找两个素数,使得其和等于该偶数. 做好了这件实…