← Back to List

1978번: 소수 찾기 ↗

Solutions

C++14
318 B | 318 chars
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
int N,ar[110],Cnt;
int main()
{
	cin>>N;
	for(int x=0; x<N; x++)
	{
		cin>>ar[x];
	}
	for(int x=0; x<N; x++)
	{
		bool check=true;
		for(int y=2; y<ar[x]; y++)
		{
			if(ar[x]%y==0) check=false;
		}
		if(check&&ar[x]>1) Cnt++;
	}
	cout<<Cnt;
}