Run ID:38450

提交时间:2022-09-10 16:53:48

#include <iostream> using namespace std; int ans; int a[] = {2, 3, 5, 7}, b[] = {1, 3, 7, 9}; int n; bool check(int x) { if(x == 1) return false; for(int i = 2; i <= x / i; i ++) { if(x % i == 0) return false; } return true; } void dfs(int x) { if(x > n) return; ans ++; for(int i = 0; i < 4; i ++) if(check(x * 10 + b[i])) dfs(x * 10 + b[i]); } int main() { cin >> n; for(int i = 0; i < 4; i ++) dfs(a[i]); cout << ans << endl; return 0; }