- MysGln 的博客
8月17日笔记
- @ 2026-8-17 13:31:20
素数判断
- 通过总量判断
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int cnt = 0; // 统计因数个数
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
cnt++;
}
}
if (cnt == 2) {
cout << "Y" << endl;
} else {
cout << "N" << endl;
}
}