ProjectEuler 003题
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题的更多相关文章
- ProjectEuler 做题记录
退役选手打发时间的PE计划 挂在这里主要是dalao们看到有什么想交流的东西可以私聊哦(站内信或邮箱吧)~~当然现在高三也不怎么能上网. 2017/8/11 595 :第一题QAQ 2017/8/1 ...
- ProjectEuler 005题
题目: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any ...
- 【LeetCode刷题系列 - 003题】Longest Substring Without Repeating Characters
题目: Given a string, find the length of the longest substring without repeating characters. Example 1 ...
- ProjectEuler 009题
题目: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For exam ...
- ProjectEuler 008题
题目: The four adjacent digits in the 1000-digit number that have the greatest product are 9 9 8 9 = 5 ...
- ProjectEuler 007题
题目:By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is ...
- ProjectEuler 006题
题目: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square ...
- ProjectEuler 004题
1 #include<iostream> 2 using namespace std; 3 4 int main() { 5 bool isPalindromic (int num); 6 ...
- nim也玩一行流,nim版的list comprehension
nim 是一门风格类似python的静态编译型语言,官方网站:http://nim-lang.org 如果你想折腾nim的编辑环境,可以用sublime text3 +插件nimlime,notepa ...
随机推荐
- 【Tips】有道云笔记中Markdown插入图片
在有道云笔记中用MarkDown插入图片 新建一个文档专门用来放图片 把所有要用的图片专门放在一个笔记里,用普通模式先同步笔记,然后用分享笔记 会有一个链接,用浏览器打开这个分享的笔记就能找到所有的图 ...
- Python多线程爬取某网站表情包
# 爬取网络图片import requestsfrom lxml import etreefrom urllib import requestfrom queue import Queue # 导入队 ...
- .net core工具组件系列之Redis—— 第一篇:Windows环境配置Redis(5.x以上版本)以及部署为Windows服务
Cygwin工具编译Redis Redis6.x版本是未编译版本(官方很调皮,所以没办法,咱只好帮他们编译一下了),所以咱们先下载一个Cygwin,用它来对Redis进行编译. Cygwin下载地址: ...
- P6106 [Ynoi2010] Self Adjusting Top Tree
P6106 [Ynoi2010] Self Adjusting Top Tree 题意 给出平面直角坐标系上若干不与坐标轴平行的处于第一象限的互不相交的线段,多次询问平面中一个第一象限的矩形与这些线段 ...
- POJ2482 Stars in Your Window 题解
Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I stil ...
- tomcat日志及logback相关日志框架
一.重点问题整理 1.1 关于logback.xml中的路径设置问题 准备金系统的logback.xml中设置的路径是: <!-- 定义日志文件 输出位置 --> <property ...
- 关于GPIO口的一些概念性问题
一.什么是GPIO? GPIO的英文全称是General-Purpose IO ports,也就是通用输入输出口. 在嵌入式系统中,经常需要控制许多结构简单的外部设备或者电路,这些设备有的需要通过CP ...
- Java类的生命周期浅析
类的生命周期?对象的生命周期?Spring bean 的生命周期?很多同学可能在学习java基础知识之初,很容易把这几个搞混.本文先来说说Java类的生命周期. 目录 知识前提 类的生命周期 加载(L ...
- Python 爬取 ajax 返回的数据
1 from urllib.request import quote, unquote 2 import random 3 import requests 4 5 #quote 将单个字符串编码转化为 ...
- Windows系统安装Mariadb数据库(zip包方式安装)--九五小庞
1.去Mariadb官网下载zip安装包 下载地址:https://downloads.mariadb.org/mariadb/10.3.31/ 2.解压压缩包到指定的安装位置 3.在安装包的data ...