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}