티스토리 뷰

1978번: 소수 찾기
https://www.acmicpc.net/problem/1978
#include <iostream>
using namespace std;

bool isPrimeNumber(int p_Num)
{
	if (p_Num < 2) return false;
	for (int i = 2; i * i <= p_Num; i++)
	{
		if (p_Num % i == 0)return false;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int count = 0;
	int checkNumberCount = 0;
	cin >> checkNumberCount;

	for (int i = 0; i < checkNumberCount; i++)
	{
		int checkNumber = 0;
		cin >> checkNumber;

		if (isPrimeNumber(checkNumber)) count++;
	}

	cout << count;
}
메모리 (KB)시간 (ms)코드 길이 (B)
20200492


Uploaded by N2T

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
링크
Total
Today
Yesterday