返回题解分享
讨论 / 题解分享/ 帖子详情

质数判断 - 题解

// https://dashoj.com/p/98
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, ans = -1;

int main() {
	cin >> n;
	for (ll i = 2; i * i <= n; i++) if (n % i == 0) ans = max(ans, max(i, n / i));
	if (ans == -1) cout << "YES" << endl;
	else cout << ans << endl;
	return 0;
}
0 回复 0 转发 0 喜欢 2 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!