Algorithm title: 10820 Send a Table (Euler function)

Source: Internet
Author: User
Tags integer range

Problem A

Send a Table

Input:standard Input

Output:standard Output

When participating in programming contests, your sometimes face the following problem:you and how to know the output For the given input values, but your algorithm are way too to slow pass the time ever. However hard you a try, you just can ' t discover the proper break-off conditions this would bring down the number of iteratio NS to within acceptable limits.

Now if the range of input values are not too big, there are a way out of this. Let your PC rattle for half a and produce a table of answers to all possible input values, encode this table into a program, submit it to the judge, et voila:accepted in 0.000 seconds! (Some would argue that's cheating, but remember:in love and programming contests are everything).

Faced with this problem during one programming contest, Jimmy decided to apply such a ' technique '. But However hard he tried, he wasn ' t able to squeeze all his pre-calculated values into a program small enough to pass the Judge. The situation looked hopeless, until he discovered the following property regarding the answers:the where answers Ted from two integers, but whenever the two input values had a common factor, the answer could is easily derived from the Answer for which the input values were divided by that factor. To put it in the other words:

Say Jimmy had to calculate a function Answer (x, y) where x and y are the both integers in the range [1, N]. When him knows Answer (x, y), he can easily derive Answer (K*x, K*y), where K. Calculations involving Answer (x, y) and K. For example if n=4, him only needs to know the answers for one out of the possible input value Combinations:answer (1, 1) , Answer (1, 2), Answer (2, 1), Answer (1, 3), Answer (2, 3), Answer (3, 2), Answer (3, 1), Answer (1, 4), Answer (3, 4), Answer (4 , 3) and Answer (4, 1). The other 5 can is derived from them (Answer (2, 2), Answer (3, 3) and Answer (4, 4) to Answer (1, 1), Answer (2, 4) from Ans Wer (1, 2), and Answer (4, 2) from Answer (2, 1)). Note This function Answer is isn't symmetric, so Answer (3, 2) can do derived from Answer (2, 3).

Now what we want you to do is:for any values of N from 1 upto and including 50000, give the number of function Jimmy has To Pre-calculate.

Input

The input file contains at most lines of inputs. Each line contains an integer less than 50001 which indicates the value of N. Input was terminated by a line which contains A zero. This line should is processed.

Output

For each line of the input produce one line of output. This line contains an integer which indicates how many values Jimmy has to pre-calculate for a certain value of N.

Sample input Output for sample input

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.