Largest prime factorTime limit:5000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 7195 Accepted Submission (s): 2554
problem DescriptionEverybody knows any number can is combined by the prime number.
Now, your task was telling me what position of the largest prime factor.
The position of Prime 2 is 1, Prime 3 are 2, and Prime 5 is 3, etc.
Specially, LPF (1) = 0.
InputEach line would contain one integer n (0 < n < 1000000).
OutputOutput the LPF (n).
Sample Input
12345
Sample Output
01213 solution thinking thought for a long time, or the use of the method of playing the table, with the prime number of the table, but not just because of the prime number and mark it, but if it is a prime number, it and its multiples of the position of the prime number to mark. Because I is constantly changing, so if it is 6, the first mark is 2, the back can be replaced with the three marks. code # Include<stdio.h> #include <string.h>int a[1100000];int main () {int N,i,j,now;memset (a,0,sizeof (a));//initialization , mark it all as 0 a[1]=0;now=0;//mark position, that is, the number of for (i=2;i<=1000000;i++) {if (a[i]==0)//If it is prime {now++;for (j=i;j<=1000000; j+=i) a[j]=now;//all multiples in the range are marked with now, and the}//i is constantly increasing, and the maximum quality factor is constantly being replaced. } while (scanf ("%d", &n)!=eof) {printf ("%d\n", A[n]);} return 0;}
201412022200-hd-largest Prime factor