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 ...
随机推荐
- 传说中的WCF(1):这东西难学吗?
WCF难学吗? 是啊,这问题估计很多人都会问,也包括阿拉在内,也有此深刻而严重的凝问. 也有人说:“如何某项技术可以化繁为简,学起来轻松一点就好了.”也许,人类开生就摆脱不了一种习性——懒惰:不过,也 ...
- Roslyn and NRefactory
1.Roslyn: 微软今天(2012-06-06)向CTP社区发布了Roslyn编译器的最新版本,它主要用于Visual Basic和C#代码,可工作于Visual Studio 2010 SP1和 ...
- JS代码平面化
重构JS代码 - 让JS代码平面化 js中的嵌套函数用的很多,很牛叉,那为何要平面化? 易懂(自己及他人) 易修改(自己及他人) 平时Ajax调用写法(基于jQuery) $.post('url' ...
- duilib开源界面库
官网: https://code.google.com/p/duilib/ 基于:http://www.viksoe.dk/code/windowless1.htm 教程: http://www.cn ...
- ARC forbids explicit message send of 'autorelease'错误
(ARC forbids explicit message send of 'autorelease'错误) 在ios中经常会遇到:ARC forbids explicit message send ...
- python 爬虫总结【转】
1.基本抓取网页 get方法 import urllib2 url = "http://www.baidu.com" response = urllib2.urlopen(url) ...
- selenium webdriver (python)
selenium webdriver (python) 第一版PDF Posted on 2013-08-30 22:59 虫师 阅读(221) 评论(0) 编辑 收藏 前言 如果你是一位有pytho ...
- 专为webkit内核而生的javascript库mango正式发布
专为webkit内核而生的javascript库mango正式发布 Mango(芒果) javascript库 求fork https://github.com/willian12345/mango ...
- [转]Python tips: 什么是*args和**kwargs?
Python tips: 什么是*args和**kwargs? 原文地址:http://www.cnblogs.com/fengmk2/archive/2008/04/21/1163766.html ...
- 去除scons构建动态库的前缀lib
如何使用scons构建工程,请参考快速构建C++项目工具Scons,结合Editplus搭建开发环境. 编译SharedLibrary项目的时候,生产的so文件时自动加上lib, 例如: env = ...