杭电oj2138

刚开始一直wrong就是发现不了错误
最后发现 “There are a lot of cases. In each case”虽然他只测试了一组。。
所以一定要好好读题!!!

#include<iostream>
#include<cmath>
using namespace std;
int sushu(int x){
	int b=1;
	//刚开始3没另外考虑 
    if(x==2||x==3) return 1;
	  for(int i=2;i<=(int)sqrt(x*1.0);i++)
	  if(x%i==0)
	  	 return 0;	  	      
	  return 1; 
}
int main(){
	int t;
	while(cin>>t)
	{	 
	int y=0;//素数个数 
	while(t--){
		int a;	
		cin>>a;
		if(sushu(a)) y++;
		
	}
	cout<<y<<endl;
	}
	
	
	return 0;
} 
发布了13 篇原创文章 · 获赞 0 · 访问量 200

猜你喜欢

转载自blog.csdn.net/weixin_45191675/article/details/104699743
今日推荐