Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <set>
- #include <cstring>
- using namespace std;
- typedef long long ll;
- bool prime[1000005];
- bool visited[1000005];
- int main() {
- ios_base::sync_with_stdio(false);
- memset(prime, true, sizeof prime);
- memset(visited, false, sizeof visited);
- prime[0] = false;
- prime[1] = false;
- for(ll i = 2; i <= 1000000; i++) {
- if(prime[i]) {
- for(ll j = i + i; j <= 1000000; j += i) {
- prime[j] = false;
- }
- }
- }
- string s;
- cin >> s;
- int ans =0 ;
- for(int i = 0; i < s.size(); i++) {
- ll tmp = 0;
- for(int j = 0; j < 6; j++) {
- if(i + j < s.size()) {
- tmp = (tmp * 10) + (s[i + j] - '0');
- if(prime[tmp] and !visited[tmp]) {
- visited[tmp] = true;
- ++ans;
- }
- }
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement