2136 largest prime factor (play table)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.