题目大意:每个素数在素数表中都有一个序号,设1的序号为0,则2
的序号为1,3的序号为2,5的序号为3,以此类推。现在要求输出所
给定的数n的最大质因子的序号,0<n<1000000。
思路:巧用素数打表法。用sum计算素数的序号,将素数连同他的倍
数一起置为它的素数序号,从小到大循环,这样数组里存放的序号就
是最大素数因子的序号了。
注意:初始化时令所有数为0,Prime[0] = Prime[1] = 1。
即Prime[i]为0是素数,Prime[i]为1为素数。改变之后Prime[i]为数i
的最大...
分类:
其他好文 时间:
2014-12-07 00:11:24
阅读次数:
178
Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.如果用DP来做,判断(begin...
分类:
其他好文 时间:
2014-12-06 16:44:58
阅读次数:
166
Largest Rectangle in HistogramGivennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of l...
分类:
其他好文 时间:
2014-12-06 16:39:46
阅读次数:
139
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:
其他好文 时间:
2014-12-06 15:19:13
阅读次数:
199
Largest prime factor
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7195 Accepted Submission(s): 2554
Problem Description
Eve...
分类:
其他好文 时间:
2014-12-05 21:21:41
阅读次数:
226
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.public class Solution { public...
分类:
其他好文 时间:
2014-12-03 22:43:28
阅读次数:
191
Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog...
分类:
其他好文 时间:
2014-12-03 22:42:18
阅读次数:
127
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:
其他好文 时间:
2014-12-03 12:11:27
阅读次数:
136
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[?2,1,?3,4,?1,2,1,...
分类:
其他好文 时间:
2014-12-01 19:06:37
阅读次数:
195
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the...
分类:
其他好文 时间:
2014-11-29 18:54:45
阅读次数:
180