Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
38450 | 王旭阳 | 超级素数 | C++ | Accepted | 1 MS | 272 KB | 581 | 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; }