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)