Largest prime factor
problem 3:Largest prime factor
题意:求600851475143的最大的质因数
代码如下:
#ifndef PRO3_H_INCLUDED
#define PRO3_H_INCLUDED
#include "prime.h"
namespace pro3{
long long solve(){
;;
;i*i<=n;++i)
){
if(isPrime(n/i))return n/i;
else if(isPrime(i))maxn=i;
}
>maxn?:maxn;
}
}
#endif // PRO3_H_INCLUDED
其中,bool isPrime(long long x)如下(后面不再赘述):
bool isPrime(long long x){
);
;i*i<=x;++i)
);
;
}
bool isPrime(long long x)
Largest prime factor的更多相关文章
- 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 ...
- HDOJ(HDU) 2136 Largest prime factor(素数筛选)
Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...
- 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- (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 60085 ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
- 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 60085 ...
- 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 ...
- 【ACM】Largest prime factor
/*打表把素数能组合的数先设置成相应的位数*/ /* if n equals two and n is No.1 position of prime factors so four position ...
- [暑假集训--数论]hdu2136 Largest prime factor
Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...
随机推荐
- C# 图片存入SQL Server数据库
OpenFileDialog openfiledialog1 = new OpenFileDialog(); if (openfiledialog1.ShowDialog() == DialogRes ...
- bitnami redmine安装、配置、备份、恢复(这篇文章靠谱)
bitnami redmine安装.配置.备份.恢复 2012-12-17 12:33 2596人阅读 评论(0) 收藏 举报 1. 安装时语言选择英文,不可以选择中文,否则不能正常运行,可以在账户里 ...
- Unit of work + Repository
(Unit of work + Repository) 今日后开启进阶模式! 谈到MVC与EntityFramework,则不得不说一说事务与仓储(Unit of work + Repository) ...
- .NET MVC通过反射获取数据修
.NET MVC通过反射获取数据修 折磨了我一个晚上的问题,奈何对物理的反射印象太深了,整天去想着物理的反射.折射怎么解.感谢少将哥哥给我的指点,经过一个晚上对反射的恶补,最终搞定了.纪念一下. 1. ...
- MogileFS
分布式文件系统 ~MogileFS~ 一.分布式文件系统 分布式文件系统(Distributed File System)是指文件系统管理的物理存储资源不一定直接连接在本地节点上,而是通过计算机网络与 ...
- 迷你 MVC
深入研究 蒋金楠(Artech)老师的 MiniMvc(迷你 MVC),看看 MVC 内部到底是如何运行的 2014-04-05 13:52 by 自由的生活, 645 阅读, 2 评论, 收藏, 编 ...
- Euclid Problem - PC110703
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10104.html 原创:Eucl ...
- Visual Stuido也有非常多的快捷键
最近看到很多同事用 VI 来开发Ruby,Python脚本. 编辑代码全部用的是快捷键,效率很高. 其实Visual Stuido也有非常多的快捷键,熟练运用后,能大大提高工作效率. 本文介绍一些最常 ...
- IIS配置PHP环境
IIS配置PHP环境(快速最新版)(转载+自创) (参考转载的) 我们知道php配置有几种: 1.CGI方式加载PHP环境,通常就是IIS里面配置解释器为php.exe,早期比较常见,目前使用较少. ...
- 筛法求质——poj2262&2909
这两道题都是哥赫巴德猜想的内容.基本的技术点都是在一个很大的数字范围里面求质数.直接判断两个数是不是质数,这种方法虽然可行但是还是很慢的.所以这两题我们使用打表! 而建立质数表的方法就是筛法求质,速度 ...