src2020/1655_goodlooknum/goodlooknum.cpp

44 lines
923 B
C++

#include <iostream>
using namespace std;
bool f[1001] = { 0 };
bool pan(int n)
{
if (n == 2) {
return 1;
}
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
return 0;
}
}
return 1;
}
bool dg(int n)
{
for (int i = 2; i * i <= n; i++) {
if (pan(i) == 1) {
int now = i;
for (int j = 1; now <= n; j++) {
now *= i;
if (now == n) {
return 1;
}
if (n%now==0&&dg(n / now) == 1) {
//cout<<now<<" "<<n-now<<endl;
return 1;
}
}
}
}
return 0;
}
int main()
{
for (int i = 10;; i++) {
f[i] = dg(i);
if (f[i] == 1 && f[i - 1] == 1) {
cout << i - 1 << " " << i;
return 0;
}
}
}