直接判断数据过大
相对而言,由2,3,5,7组成的数更少,则先筛选出由2,3,5,7组成的数,再判断这些数中的质数个数即可
#include <iostream>
using namespace std;
int main()
{printf("1903");return 0;
}
#include <iostream>
#include<cmath>
using namespace std;
typedef long long ll;
const ll n = 20210605LL;
ll h[n + 10] = {0}, p[n + 10];
int main(){ll num = 0, count = 0, t, t1, sqr, flag;for(ll i = 2; i <= n; i++){t1 = i;while(t1){t = t1 % 10;if(t == 2 || t == 3 || t == 5 || t == 7){t1 /= 10;}else break;}if(t1 == 0) p[num++] = i;}for(ll i = 0; i < num; i++){sqr = (ll)sqrt(p[i]*1.0);flag = 0;for(ll j = 2; j <= sqr; j++){if(p[i] % j == 0) {flag = 1;break;}}if(!flag) {count++;printf("%lld,", p[i]);}}printf("%lld", count);return 0;
}