Heng_Xin 题解分享 · 2024/5/31
纯质数(结果填空) - 题解
1 不是质数 ```cpp #include <cstdio> #include <vector> #include <unordered_set> #include <functional> // #include <bits/stdc++.h> using namespace std; using ll = long long; bool isZs(ll x) { for (ll i = 2; i * i <= x; ++i) if (x % i) continue; else return false; return x > 1; } int main() { unordered_set<ll> zs = {2, 3, 5, 7}; ll res = 0; for (ll i = 1; i <= 20210605; ++i) { if ( isZs(i) ) { ll x = i; while (x) { if (!zs.count(x % 10)) goto NO; x /= 10; } ++res; // printf("%d Yes\n", i); NO: ; } } printf("%lld\n", res); return 0; } ```
查看全文
1 0 0 10