Nefu 117 Prime theorem

Source: Internet
Author: User

Xiao Ming is a clever boy and has a strong interest in number theory. He found that it was difficult to ask how many primes between 1 and 10n, and it was difficult to determine the size of the N value. Now the question is, tell you the value of N, let you help xiaoming calculate the number of primes less than 10n total number of bits?
Input
The input data has several groups, each set of data contains 1 integers n (1 < n < 1000000000), and the processing ends if EOF is encountered.
Output
corresponding to each set of data, the number of digits less than 10n is output in one line, and the format is shown in sample output. The output of the same set of data, with a blank space between each mantissa, with no spaces at the end of the line.
Sample Input
37
Sample Output
36

Prime theorem: The number of prime numbers that are less than positive real x is recorded as f (x), so the growth of X is f (x)/(X/log (x)) = 1;

Inference: PN is the nth prime, then PN ~ nlog (n);

The number of digits of the formula: LOG10 (x) + 1;

#include <map>#include<queue>#include<stack>#include<cmath>#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#defineINF 1000000001#definell __int64#defineLson l,m,rt<<1#defineRson m+1,r,rt<<1|1using namespacestd;Const intMAXN =50010;intN;intMain () { while(Cin >>N) {cout<< (int) (N-LOG10 (n1.0)-Log10 (log (10.0))) +1<<Endl; }    return 0;}

Nefu 117 Prime theorem

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.