文章目录
思路
这就是一个简单的DFS板题。
代码1:
#include <bits/stdc++.h>
using namespace std;
int n, sum = 1;
bool o(int t) {
for (int i = 2; i <= sqrt(t); i++) {
if (t % i == 0)
return 0;
}
return 1;
}
bool yu(int t) {
for (int i = 1; i <= n; i++) {
if (o(t) == 0 || t == 1)
return 0;
t /= 10;
}
return 1;
}
void cha(int book) {
if (book >= sum * 10)
return;
if (yu(book))
printf("%d\n", book);
cha(book + 1);<