HDU acmsteps 2.1.2 how many prime numbers

Source: Internet
Author: User
How many prime numbers

Time Limit: 3000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)

Total submission (s): 5139 accepted submission (s): 1684

Problem description

Give you a lot of positive integers, just to find out how many prime numbers there are.

Input

There are a lot of cases. in each case, there is an integer n representing the number of Integers to find. each integer won't exceed 32-bit signed integer, and each of them won't be less than 2.

Output

For each case, print the number of prime numbers you have found out.

Sample Input

 
32 3 4

Sample output

 
2
 
 
1:# Include <iostream>
 
2:# Include <cmath>
 
3:Using NamespaceSTD;
 
4:BoolIsprime (IntN ){
 
5:IntSqt = SQRT (N * 1.0 );
 
6:For(IntI = 2; I <= sqt; I ++)
 
7:If(N % I = 0)
 
8:Return False;
9:Return True;
 
10:}
 
11:IntMain (){
 
12:// Freopen ("in.txt", "r", stdin );
 
13:For(IntN; CIN> N ;){
 
14:IntNum = 0, temp;
 
15:While(N --){
 
16:Cin> temp;
 
17:Num + = isprime (temp );
18:}
 
19:Cout <num <'\ N';
 
20:}
 
21:}

determine the prime number.

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.