代码,40分报错,有大佬会的么
查看原帖
代码,40分报错,有大佬会的么
647551
yuenze0416楼主2023/8/1 21:33
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e6 + 7;
int pr[N], ct;
bool noP[N];
void euler(int n) { //欧拉筛
	noP[1] = true;
	for (int i = 2; i < n; i++) {
		if (!noP[i]) pr[++ct] = i;
		for (int j = 1; pr[j]*i < n; j++) {
			noP[pr[j]*i] = true;
			if (i%pr[j] == 0)
				break;
		}
	}
}
int main() {
	int x, y;
	scanf("%d%d", &x, &y);
	if (x > y) swap(x, y);
	euler(y);
	for (int i = 1; i <= ct; i++) {
		if (pr[i] > x) {
			printf("%d", ct - i+1);
			return 0;
		}
	}
	return 0;
}

感谢感谢 QWQ

2023/8/1 21:33
加载中...