Files
python/TangDou/ShuLun/SL4.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
689 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
//利用分解质因数模板,扩展出是不是漂亮数
bool isPLS(int x) {
for (int i = 2; i * i <= x; i++) {
int s = 0;
while (x % i == 0) x /= i, s++;
//只有1个因子就不是漂亮数
if (s == 1) return false;
}
//如果存在一个大的质数因子,也不是漂亮树
if (x > 1) return false;
return true;
}
int m, n, cnt;
int main() {
cin >> m >> n;
for (int i = m; i < n; i++)
if (isPLS(i) && isPLS(i + 1)) {
printf("%d %d\n", i, i + 1);
cnt++;
}
if (!cnt) printf("no find");
return 0;
}