Problem 3
Problem 3
# Problem_3.py
"""
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
600851475143的最大质因数
"""
from math import sqrt num = 600851475143
size = int(sqrt(num)) + 1 is_prime = [True for i in range(size)] for i in range(2, size):
if is_prime[i]:
j = 2
while i * j < size:
is_prime[i * j] = False
j += 1 for i in range(size - 1, 1, -1):
if is_prime[i] and num % i == 0:
print(i)
break
Problem 3的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- python中经常使用的字典内建函数
1.len(mapping) 返回映射的长度(键-值对的个数) 2.hash(obj) 返回obj的哈希值 >>> myDict = {'na ...
- Item 8:析构函数不要抛出异常 Effective C++笔记
Item 8: Prevent exceptions from leaving destructors. 析构函数不要抛出异常 因为析构函数经常被自己主动调用,在析构函数中抛出的异常往往会难以捕获,引 ...
- C#实现动态调用Windows DLL
调用方法: object obj = WinDllInvoke("Kernel32.dll", "Beep", , }, typeof(void)); 函数代码 ...
- poj--2236--棋盘问题(dfs)
棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 31183 Accepted: 15469 Descriptio ...
- 【Codeforces 258B】 Sort the Array
[题目链接] http://codeforces.com/contest/451/problem/B [算法] 模拟 在序列中找到一段单调递增的子序列,将这段序列反转,然后判断序列是否变得单调递增,即 ...
- [转载]RouteOS安装设置
原文地址:RouteOS安装设置作者:抟鹏追梦 RouteOS2.7.4可以将一台普通的PC机变成一台专业的路由器,高到ISP的核心路器/认证网关-因为它功能强大稳定,低到家庭网关防火墙-因为它免费. ...
- Oracle 11g RAC for LINUX rhel 6.X silent install(静默安装)
一.前期规划 1.硬件环境 CPU: Intel(R) Xeon(R) CPU E7-4820 v4 @ 2.00GHz 8*10核 内存:512GB OCR:2147*5 MB DATA1:2TB ...
- 5、Iterator迭代器的使用
package cn.itcast_02; import java.util.ArrayList; import java.util.Collection; import java.util.Iter ...
- 很全很全的JavaScript的模块讲解
介绍 模块通常是指编程语言所提供的代码组织机制,利用此机制可将程序拆解为独立且通用的代码单元.所谓模块化主要是解决代码分割.作用域隔离.模块之间的依赖管理以及发布到生产环境时的自动化打包与处理等多个方 ...
- 杭电1003 Max Sum TLE
这一题目是要求连续子序列的最大和,所以在看到题目的一瞬间就想到的是把所有情况列举出来,再两个两个的比较,取最大的(即为更新最大值的意思),这样的思路很简单,但是会超时,时间复杂度为O(n^3),因为有 ...