1 //题目:The prime factors of 13195 are 5, 7, 13 and 29.
2 //What is the largest prime factor of the number 600851475143 ?
 1 #include<iostream>
2 using namespace std;
3 int main() {
4 long long N = 600851475143;//int和long都为32位,long long 为64位
5 int i;
6 bool isPrime(long long num);
7 long long res;
8 for(i=2; i<=N;i++){
9 while(isPrime(i) && N%i == 0.0){
10 N = N/i;
11 res = i;
12 }
13 }
14 cout << res << endl;
15 system("pause");
16 return 0;
17 }
18 bool isPrime(long long num){
19 int i=0;
20 for(i = 2; i*i <= num; i++){
21
22 if(num%i == 0.0)
23 return false;
24 }
25 return true;
26 }

ProjectEuler 003题的更多相关文章

  1. ProjectEuler 做题记录

    退役选手打发时间的PE计划 挂在这里主要是dalao们看到有什么想交流的东西可以私聊哦(站内信或邮箱吧)~~当然现在高三也不怎么能上网. 2017/8/11  595 :第一题QAQ 2017/8/1 ...

  2. ProjectEuler 005题

    题目: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any ...

  3. 【LeetCode刷题系列 - 003题】Longest Substring Without Repeating Characters

    题目: Given a string, find the length of the longest substring without repeating characters. Example 1 ...

  4. ProjectEuler 009题

    题目: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For exam ...

  5. ProjectEuler 008题

    题目: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 = 5 ...

  6. ProjectEuler 007题

    题目:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is ...

  7. ProjectEuler 006题

    题目: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square ...

  8. ProjectEuler 004题

    1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 bool isPalindromic (int num); 6 ...

  9. nim也玩一行流,nim版的list comprehension

    nim 是一门风格类似python的静态编译型语言,官方网站:http://nim-lang.org 如果你想折腾nim的编辑环境,可以用sublime text3 +插件nimlime,notepa ...

随机推荐

  1. easyui-textbox使用value设置默认值失效

    1,使用easyu-textbox的value参数设置默认值失效,easyui-textbox放到dialog弹框中,当dialog的closed为false时,也就是打开dialog时,设置的val ...

  2. 解决 centerOS7部署ajango2.2.x版本 报SQLite 3.8.3 or later is required (found 3.7.17).错误

    在CentOS7上部署Django的时候,遇到了一些问题,写篇笔记记录解决过程. 报错信息 当python3 manage.py runserver启动django项目的时候,就会出现报错信息如下: ...

  3. win 10,Maven 配置

    来源:https://www.cnblogs.com/lihan829/p/11503497.html 所需工具 : JDK 1.8 Maven 3.6.2 Windows 10 注Maven 3.2 ...

  4. SSM整合文件框架

    1.项目架构如图 web3.0项目,tomcat9.0,自动生成web.xml文件 按照mybatis配置,先自动生成dao层,更改相应信息 我mybatis如何配置:   https://www.c ...

  5. 深入刨析tomcat 之---第1篇,解决第1,2章bug 页面不显示内容Hello. Roses are red.

    writedby 张艳涛, 第一个问题是不显示index.html网页 19年才开始学java的第二个月,就开始第一遍看这本书,我估计当初,做第一章的一个案例,自己写代码,和验证就得一天吧,当初就发现 ...

  6. 谈谈 C++ STL 中的迭代器

    C++中的迭代器和指针 在前面的内容中我们简单讲过,STL主要是由三部分组成 容器(container),包括vector,list,set,map等 泛型算法(generic algorithm), ...

  7. webRTC的标准与发展

    Web实时通信(WebRTC)是标准,协议和JavaScript API的集合,两者的组合可实现浏览器(对等)之间的对等音频,视频和数据共享.WebRTC无需依赖第三方插件或专有软件,而是将实时通信转 ...

  8. 单片机学习(五)LCD1602和矩阵键盘的使用

    目录 LCD1602的使用 矩阵键盘的使用 矩阵键盘相关电路图 按键检测扫描 制作密码输入器 LCD1602的使用 首先LCD1602是外接在开发板上的液晶屏外设,如图所示: 我们主要使用它来代替动态 ...

  9. 解决 OnDropFiles 可能无响应的问题【转】

    大多数程序都有接收拖放文件的功能,即是用鼠标把文件拖放到程序窗口上方,符合格式的文件就会自动被程序打开.最近自己对编写的程序增加了一个拖放文件的功能,在 Windows XP.Windows Serv ...

  10. HCIA-网络层包结构

    网络层 关心-->转发 IPV4协议 IPV6协议 寻址 转发 标识位置 IPV6: 86DD MAC定位局部 网络定位全局 对于上层数据如果过大,网络层可以分组,实现分组转发 环路:发送了一个 ...