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