求助
查看原帖
求助
946093
_PSH_楼主2024/11/9 07:17

前6点AC后几点RE 附上代码

#include <bits/stdc++.h>
#define I using
#define likeplaying namespace
#define Genshin std
#define int long long
I likeplaying Genshin;
const int maxn = 1e8 + 5;
bool boo[maxn];
int prim[maxn];
signed main() {
	int n;
	cin >> n;
	memset(boo, false, sizeof(boo));
	for (int i = 2; i * i <= n * n; i++) {
		if (!boo[i]) {
			for (int j = i * i; j <= n * n; j += i) {
				boo[j] = true;
			}
		}
	}
	for (int i = 2, v = 0; i <= n * 2; i++) {
		if (boo[i] == false) {
			prim[v] = i;
			v++;
		}
	}
	for (int i = 0; i * i <= n; i++) {
		if (n % prim[i] == 0) {
			cout << n / prim[i];
			return 0;
		}
	}
}

2024/11/9 07:17
加载中...