Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const ll maxn = 1e6 + 10;
- int main() {
- string s;
- cin >> s;
- int cnt=0;
- bool is_prime[maxn];
- memset(is_prime, true, sizeof is_prime);
- is_prime[0] = false;
- is_prime[1] = false;
- for(ll i = 2; i <= maxn; i++) {
- if(is_prime[i]) {
- for(ll j = i * i; j <= maxn; j += i) {
- is_prime[j] = false;
- }
- }
- }
- vector<bool>visited(1000000,false);
- for(int i = 0; i < (int) s.size(); i++) {
- string tmp = "";
- for(int j = i; j < min((int) s.size(), i + 6); j++) {
- tmp += s[j];
- int string_to_int=0;
- for(int k = 0;k<(int)tmp.size();k++){
- string_to_int=string_to_int*10+(tmp[k]-'0');
- }
- bool dali_e_prost=true;
- if(dali_e_prost==true && visited[string_to_int]==false && is_prime[string_to_int] == true){
- cnt++;
- visited[string_to_int]=true;
- }
- }
- }
- cout<<cnt<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement