B2128超时
  • 板块学术版
  • 楼主ytezwsw_xjy
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/5/2 19:29
  • 上次更新2024/5/2 19:50:10
查看原帖
B2128超时
1210473
ytezwsw_xjy楼主2024/5/2 19:29
#include<bits/stdc++.h>
using namespace std;
int zs(int x){
	int s=1;
	for(int i=2;i<=x-1;i++){
		if(x%i==0){
			s=0;
		}
	}
	if(s==1){
		return true;
	}else{
		return false;
	}
}
int main(){
	int n;
	int s1=0;
	cin>>n;
	for(int i=2;i<=n;i++){
		int b=zs(i);
		if(b==1){ 
			s1+=1;
		}
	}
	cout<<s1<<endl;
	return 0;
}
2024/5/2 19:29
加载中...