The number of digits in the number of Nefu primes (prime theorem)

Source: Internet
Author: User

Number of digits of prime number
problem:117 Time limit:1000ms Memory limit:65536k
Description
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
There are several groups of input data, each set of data containing 1 integers n (1 < N < 1000000000), 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



Ideas:

prime theorem: π (x) indicates the number of primes less than positive real numbers, with π (x)/(X/LNX) approximate =1

Inference: Nth prime number PN ~ NLNN


So the number of digits is: LG (10^N/LN (10^n)) +1


Accepted 872k 3ms C + + (g++ 3.4.3) 284 #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath>using namespace Std;int main () {    double n;    while (~SCANF ("%lf", &n))    {        double C;        C=N-LOG10 (n)-log10 (log (ten));        printf ("%d\n", int (c) +1);}    }




The number of digits in the number of Nefu primes (prime theorem)

Related Article

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.