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 Input12345
Sample Output01213
Authorwiskey
Sourcehdu 2007-11 Programming Contest_warmupTest instructions: is the position of the maximum prime factor in the prime number table.
1#include <stdio.h>2#include <math.h>3#include <queue>4#include <vector>5#include <stack>6#include <map>7#include <string>8#include <cstring>9#include <algorithm>Ten#include <iostream> One using namespacestd; A #defineN 1000000 - intA[n]; - voidPD () { the intn=0, I,t,j; -Memset (A,0,sizeof(a)); - for(i=2; i<=n;i++)//The number of multiples of each number of the current number of assigned prime numbers can be overridden oh because the maximum factor to overwrite - { + if(a[i]==0) - { +n++;//position of Prime I A for(j=i;j<=n;j+=i)//constructs the position of the temporary maximum prime factor of J ata[j]=N; - } - } - } - intMain () - { in inti; - PD (); to while(~SCANF ("%d",&i)) + { -printf"%d\n", A[i]); the } * return 0; $}
2136 largest prime factor (play table)