Help!!!
查看原帖
Help!!!
1611271
lidabing0818楼主2025/6/22 16:56

60分求调QwQ

#include <bits/stdc++.h>
using namespace std;

bool isPrime(int x) {
	if(x <= 1) return false;
	for(int i = 2;i * i <= x;i ++) {
		if(x % i == 0) return false;
	}
	return true;
}
int main() {
	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1;i <= n;i ++) {
		if(isPrime(i)) cnt ++;
	}
	cout << cnt;	
	return 0;
}
2025/6/22 16:56
加载中...