05: Number of prime number input and 05 prime number input

Source: Internet
Author: User

05: Number of prime number input and 05 prime number input
05: Number of prime numbers

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

Evaluate the number of integers between 11 and n (including n), which is both a prime number and a return number.

Input
An integer n greater than 11 and less than 1000.
Output
Returns the number of prime numbers between 11 and n.
Sample Input
23
Sample output
1
Prompt
The return number refers to the symmetric number, for example, 292,333.
Source
06 introduction to computing
1 # include <iostream> 2 # include <cstdio> 3 # include <queue> 4 # include <cmath> 5 using namespace std; 6 int ans [10001]; 7 int now; 8 int tot; 9 int vis [10001]; 10 int main () 11 {12 int n; 13 cin> n; 14 for (int I = 2; I <= sqrt (n + 0.5); I ++) 15 {16 if (vis [I] = 0) 17 {18 for (int j = I * I; j <= n; j = j + I) 19 vis [j] = 1; 20} 21} // returns the prime number 22 for (int I = 11; I <= n; I ++) 23 {24 if (vis [I] = 1) 25 {26 continue; 27} 28 else 29 {30 int t = I; 31 int g = t % 10; 32 t = t/10; 33 int s = t % 10; 34 if (t/10 = 0) 35 {36 if (g = s) 37 tot ++; 38} 39 else40 {41 t = t/10; 42 int B = t % 10; 43 if (g = B) 44 tot ++; 45} 46 47} 48} 49 cout <tot; 50 return 0; 51}

 

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.