求助,下关注雨了
  • 板块灌水区
  • 楼主CSP400pts
  • 当前回复6
  • 已保存回复6
  • 发布时间2024/8/27 19:30
  • 上次更新2024/8/27 21:09:51
查看原帖
求助,下关注雨了
1331383
CSP400pts楼主2024/8/27 19:30

Code:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1e6+5;
int n,b,ans;
int vis[N];
void chk() {
	for(int i=2; i<=N; i++) {
		if(vis[i]==0) {
			vis[i]=i;
			for(int j=i*i; j<=N; j+=i) {
				vis[j]=i;
			}
		}
	}
}
int main() {
	chk();
	cin>>n>>b;
	for(int i=1; i<=n; i++)
		if(vis[i]<=b) ans++;
	cout<<ans<<endl;
	return 0;
}
2024/8/27 19:30
加载中...