'commit'
This commit is contained in:
27
TangDou/ShuLun/SL4.cpp
Normal file
27
TangDou/ShuLun/SL4.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user