Number of nefu117 primes (prime theorem + large number of digits formula)

Source: Internet
Author: User
Tags ming

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 Xiao Ming 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
3
7
Sample_output
3
6
Topic Analysis:1. Prime number theorem

The difference between 2.floor and int, function floor () is rounded down, return double;int coercion type conversion, rounding to 0, that is, their negative number processing result is different

3. The large number of digits formula, which makes X=10^m (the integer part of M +1 is the number of digits of the large number x), has M=LG (x)

Reference Code:

#include 
#include #include #include #include #include #include #define
MAXN 1500
using namespace std;
int main ()
{
  //Freopen ("Input.txt", "R", stdin);
   Double N;
   while (cin>>n) {//prime theorem + large number of digits formula
     double ans=n-log10 (n)-log10 (log (10.0));
     cout<


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.