Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define f first
- #define s second
- #define endl '\n'
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(0);
- string st;
- cin >> st;
- bool a[1000001] = {0};
- a[1] = 1;
- for (int i = 2; i < 1000; i++)
- {
- if (!a[i])
- {
- for (int j = i*i; j <= 1000000; j+=i)
- {
- a[j] = 1;
- }
- }
- }
- set<int> s;
- for (int i = 0; i < st.size(); i++)
- {
- int p = 0;
- for (int j = 0; j+i < st.size(); j++)
- {
- p *= 10;
- p += (st[j+i] - '0');
- if (!a[p])
- {
- s.insert(p);
- }
- }
- }
- if (st == "1")
- {
- cout << 1;
- }
- else
- {
- cout << s.size();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement