50pts玄关求救!!!
查看原帖
50pts玄关求救!!!
1495378
csc0987楼主2025/1/23 11:15
#include<bits/stdc++.h>
using namespace std;
bool p(long long x)
{
	if(x<2) return false;
	if(x==2) return true;
	for(int t=2;t*t<=x;t++)
	{
		if(x%t==0) return false;
	}
	return true;
}
int main()
{
	long long n,num=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(p(i)) num++;
	}
	cout<<num;
	return 0;
}
2025/1/23 11:15
加载中...