(Problem 3)Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> #define N 600851475143 bool prim(int n)
{
int i;
for(i=; i*i<=n; i++)
{
if(n%i==)
return false;
}
return true;
} int main()
{
long long s=sqrt(N);
while(s--)
{
if(s%!= && prim(s) && (N%s==))
{ printf("%lld\n",s);
break;
}
}
return ;
}
Answer:
|
6857 |
(Problem 3)Largest prime factor的更多相关文章
- (Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- R语言学习——欧拉计划(3)Largest prime factor 求最大质因数
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...
- HD-ACM算法专攻系列(18)——Largest prime factor
题目描述: 源码: 需要注意,若使用cin,cout输入输出,会超时. #include"iostream" #include"memory.h" #defin ...
- (Problem 7)10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. ...
- (Problem 4)Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- 杭电 2136 Largest prime factor(最大素数因子的位置)
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- The largest prime factor(最大质因数)
1. 问题: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
随机推荐
- web api 开发之 filter
1.使用filter之前应该知道的(不知道也无所谓,哈哈!) 谈到filter 不得不先了解下aop(Aspect Oriented Programming)面向切面的编程.(度娘上关于aop一大堆 ...
- HDU 1851 A Simple Game
典型的尼姆博弈,在n对石子中,告诉你每堆的数目和每次从该堆最多可以取的数目,求最终谁将其取完. 题解:SG(i)=mi%(li+1),求异或值即可. #include <cstdio> i ...
- JS获取整个HTML网页代码 - Android 集美软件园 - 博客频道 - CSDN.NET
JS获取整个HTML网页代码 - Android 集美软件园 - 博客频道 - CSDN.NET JS获取整个HTML网页代码 分类: Android提高 2012-01-12 23:27 1974人 ...
- 为什么webview.loadUrl("javascript:function() ")不执行?
这几天搞webview 但是常常有时候会出现webview.loadurl 没有反映的情况对现在的分析如下: 情况一:webview.loadurl 的加载是在另一个线程中执行必须要在webview加 ...
- hpu校赛--雪人的高度(离散化线段树)
1721: 感恩节KK专场——雪人的高度 时间限制: 1 Sec 内存限制: 128 MB 提交: 81 解决: 35 [提交][状态][讨论版] 题目描述 大雪过后,KK决定在春秋大道的某些区间 ...
- 学习日记之模板方法模式和 Effective C++
模板方法模式: 定义:定义一个操作中的算法的骨架.而将一些步骤延伸到子类中.模板方法使得子类能够不改变算法的结构就可以重定义该算法的某些特定步骤. (1),用了继承,而且肯定这个继承有意义的情况下.就 ...
- 软碟通UltraISO 9.65.3237官方注册版
UltraISO软碟通是一款功能强大.方便实用.老牌优秀的光盘映像文件制作/编辑/转换工具:可直接编辑ISO文件,从ISO中提取文件和目录:也可从CD – ROM制作光盘映像或者将硬盘上的文件制作成I ...
- C# Code Snip
1.Tryf + TAB+TAB try { } finally { } 2.Prop+Tab+Tab public int MyProperty { get; set; } 3. #region + ...
- 使用PowerShell 命令集进行SQL Server 2012 备份和还原
最近心相不错,所以打算翻译一些英文文档做福利,原文在此,翻译有不足的地方还请各位兄弟指点. 讨论什么是DBA最重要的工作的时候,你最常听到就是一条就是DBA只要做好备份和恢复.事实如此,如果你不做备份 ...
- HtmlUnit+Jsoup 解决爬虫无法解析执行javascript的问题
本人最近在研究爬虫.作为一个新手.研究了些爬虫框架,发现所有开源的爬虫框架很多,功能也很齐全,但唯独遗憾的是,目前还没有发现那个爬虫对js完美的解释并执行.看了浅谈网络爬虫爬js动态加载网页(二)之后 ...