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的更多相关文章

  1. 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 ...

  2. HDOJ(HDU) 2136 Largest prime factor(素数筛选)

    Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...

  3. 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor

    Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  4. (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 ...

  5. 2136 Largest prime factor(打表)

    Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...

  6. 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 ...

  7. 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 ...

  8. 【ACM】Largest prime factor

    /*打表把素数能组合的数先设置成相应的位数*/ /* if n equals two and n is No.1 position of prime factors  so four position ...

  9. [暑假集训--数论]hdu2136 Largest prime factor

    Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...

随机推荐

  1. C#:判断当前程序是否通过管理员运行

    原文:C#:判断当前程序是否通过管理员运行 public bool IsAdministrator() { WindowsIdentity current = WindowsIdentity.GetC ...

  2. html postMessage 创建聊天应用

    应用说明: 这个例子演示如何在门户页面以iframe方式嵌入第三方插件,示例中使用了一个来域名下的应用部件,门户页面通过postMessage来通信.iframe中的聊天部件通过父页面标题内容的闪烁来 ...

  3. Random随机数

    Random类的常用方法 方法 备注 Int nextInt() 返回一个int类型的随机数 Int nextInt(n) 返回一个0到n之间的数,不包括n Double nextDouble() 返 ...

  4. Javascript多线程引擎(一)

    Javascript多线程引擎(一) Javascript 天生是单线程的语言, 不支持synchronized等线程操作, 但是这便不妨碍Javascript作为web语言中最具有魅力语言之一. 虽 ...

  5. IOS UI 第一篇:基本UI

    1. UI 书写 最基本创建一个label 标签 写一个first rate :      UILabel *label = [[UILabel alloc] initWithFrame:CGRect ...

  6. MS SQL优化

    数据库优化实践[MS SQL优化开篇]   数据库定义: 数据库是依照某种数据模型组织起来并存在二级存储器中的数据集合,此集合具有尽可能不重复,以最优方式为特定组织提供多种应用服务,其数据结构独立于应 ...

  7. nhibernate+autofac+mvc的demo

    想自己做一个小的demo.目的是能够提供一个系统架构,在这个基础上,可以快速开发一些小型的系统.

  8. D13

    =-=由于本人有极度强迫症啊.. 然后这个博客又不能改顺序.. 前几天由于台风是在宾馆写题..简直各种没有效率..所以今天就先草草写下题解,之后再完善吧 T1:字符串处理 c++的话,解决读空格继续读 ...

  9. String和StringBuilder的使用

    如果有理解错误的地方希望有朋友能指出,谢谢!   String是特殊的引用类型的,更像值类型,StringBuilder的是规规矩矩引用类型的.   首先看这样的对比图,Equals()方法是判断两个 ...

  10. 顺手的Linux发行版及其工具推荐

    从Windows切换到Linux已经有半年多的时间了,简单给大家推荐一些个人感觉不错的软件,主要都是和开发相关的通用软件--- 0.archlinux  挑一个比较顺手的linux发行版当然是首要任务 ...