(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 600851475143 ?
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> #define N 600851475143 bool prim(int n)
{
int i;
for(i=; i*i<=n; i++)
{
if(n%i==)
return false;
}
return true;
} int main()
{
long long s=sqrt(N);
while(s--)
{
if(s%!= && prim(s) && (N%s==))
{ printf("%lld\n",s);
break;
}
}
return ;
}
|
Answer:
|
6857 |
(Problem 3)Largest prime factor的更多相关文章
- (Problem 41)Pandigital prime
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- 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 ...
- HD-ACM算法专攻系列(18)——Largest prime factor
题目描述: 源码: 需要注意,若使用cin,cout输入输出,会超时. #include"iostream" #include"memory.h" #defin ...
- (Problem 7)10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. ...
- (Problem 4)Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- 杭电 2136 Largest prime factor(最大素数因子的位置)
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 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 ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
随机推荐
- [转]swift 学习资源 大集合
今天看到了一个swift的学习网站,里面收集了很多学习资源 [转自http://blog.csdn.net/sqc3375177/article/details/29206779] Swift 介绍 ...
- QT Sleep(最佳的平衡:一边发送消息,一边睡眠)
转自:http://xiangjie88.iteye.com/blog/898417 sleep()//秒msleep()//毫秒usleep()//微秒以前为了模拟鼠标点击用过这些函数,可以让进程中 ...
- opencv-python 学习笔记2:实现目光跟随(又叫人脸跟随)
如果机器人的脸能随着前方人脸而转动,你会不会觉得这种互动很有意思.年前的时候,学习了一下opencv,通过opencv可以简单的实现人脸跟随.再加上几个舵机控制头部转动,机器人就可以互动了.呵呵 这里 ...
- APUE学习之------------信号
在学习一个东西的时候我总是喜欢去问这样做的理由是什么?也喜欢去究竟他的历史.从中你可以发现所有的设计都在不断改进出来的,从来就没有一个设计是一开始就是完美的.好比是人,之初,性也许是善的,如果我们不通 ...
- Android调用系统关机与重启功能
我是在android源码里编译的package/apps/,因为需要调用的关机接口是不对上层开放的,在eclipse里面不能调用. 我主要是介绍调用android的关机功能,因为在调试过程中,关机的一 ...
- Windows Server 2012 安装dll到GAC
使用Windows管理员打开PowerShell: 运行以下命令: Set-location "c:\tools\gac" [System.Reflection.Assembly] ...
- Ext JS学习第十四天 Ext基础之 Ext.DomHelper
此文用来记录学习笔记 •我们已经学过了Element这个类,无疑是非常强大的,里面提供了丰富的方法供我们使用,但是Ext为了更加的方便我们去操作DOM元素,特提供了DomHelper这个辅助的工具 ...
- 使用jsonEditor打造一个复杂json编辑器
最近研究一个web版的json编辑器,在github中搜索,发现了这个利器. https://github.com/jdorn/json-editor 几经研究,终于把该控件的大部分功能研究透彻. 发 ...
- 如何在macox下面配置集成ios和android游戏教程
教程截图: 1.准备工作,配置开发环境: 开发环境:mac ox 10.7.3 + xcode4.2 + ndk r7 + eclipse helios 部署环境:中兴v880 root过了 ...
- shell 脚本中$$,$#,$?分别代表什么意思?
$0 这个程式的执行名字$n 这个程式的第n个参数值,n=1..9$* 这个程式的所有参数,此选项参数可超过9个.$# 这个程式的参数个数$$ 这个程式的PID(脚本运行的当前进程ID号)$! 执行上 ...