Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define f first
  3. #define s second
  4. #define endl '\n'
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. ios::sync_with_stdio(0);
  11. string st;
  12. cin >> st;
  13. bool a[1000001] = {0};
  14. a[1] = 1;
  15. for (int i = 2; i < 1000; i++)
  16. {
  17. if (!a[i])
  18. {
  19. for (int j = i*i; j <= 1000000; j+=i)
  20. {
  21. a[j] = 1;
  22. }
  23. }
  24. }
  25. set<int> s;
  26. for (int i = 0; i < st.size(); i++)
  27. {
  28. int p = 0;
  29. for (int j = 0; j+i < st.size(); j++)
  30. {
  31. p *= 10;
  32. p += (st[j+i] - '0');
  33. if (!a[p])
  34. {
  35. s.insert(p);
  36. }
  37. }
  38. }
  39. if (st == "1")
  40. {
  41. cout << 1;
  42. }
  43. else
  44. {
  45. cout << s.size();
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement