Advertisement
sasa2742002

Untitled

Apr 18th, 2023
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #include <ext/pb_ds/tree_policy.hpp>
  5. using namespace __gnu_pbds;
  6. #define T     \
  7.   ll rrr;     \
  8.   cin >> rrr; \
  9.   for (ll w1 = 0; w1 < rrr; w1++)
  10. #define cin(vec, a) for (ll i = 0; i < a && cin >> vec[i]; i++)
  11. #define cout(vec, a) for (ll i = 0; i < a && cout << vec[i] << " "; i++)
  12. #define MOD 1000000007
  13. #define PI 3.14159265
  14. #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
  15. #define all(v) v.begin(), v.end()
  16. #define rall(v) v.rbegin(), v.rend()
  17. #include <iostream>
  18. #define INF 1e9
  19. #define mod 1000000007
  20. #include <string>
  21. #define el '\n'
  22. #define sp ' '
  23. #define loop(n) for (int i = 0; i < n; i++)
  24. typedef long long ll;
  25. #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
  26. #define multi_ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
  27. template <typename O = int>
  28. istream &operator>>(istream &in, vector<O> &v)
  29. {
  30.   for (auto &x : v)
  31.     in >> x;
  32.   return in;
  33. }
  34. template <typename O = int>
  35. ostream &operator<<(ostream &out, const vector<O> &v)
  36. {
  37.   for (const O &x : v)
  38.     out << x << ' ';
  39.   return out;
  40. }
  41. void sasa()
  42. {
  43.   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  44. #ifndef ONLINE_JUDGE
  45.   freopen("input4.txt", "r", stdin), freopen("output4.txt", "w", stdout);
  46. #endif
  47. }
  48.  
  49. ///////////////////////////////////////// code //////////////////////////////////////////////////////////////////////////
  50. vector<ll> primes;
  51. vector<bool> is_prime(1000001, true);
  52. void sieve()
  53. {
  54.   is_prime[0] = is_prime[1] = false;
  55.   for (ll i = 2; i * i <= 1000000; i++)
  56.   {
  57.     if (is_prime[i])
  58.     {
  59.       for (ll j = i * i; j <= 1000000; j += i)
  60.       {
  61.         is_prime[j] = false;
  62.       }
  63.     }
  64.   }
  65.   for (ll i = 2; i <= 1000000; i++)
  66.   {
  67.     if (is_prime[i])
  68.       primes.push_back(i);
  69.   }
  70. }
  71. void solve()
  72. {
  73.   ll l, r, res = 0;
  74.   string s;
  75.   cin >> l >> r;
  76.   cin >> s;
  77.   l--;
  78.   r--;
  79.   sieve();
  80.   //cout << primes.size() << el;
  81.   for (int i = l; i <= r; i++)
  82.   {
  83.     string k = to_string(primes[i]);
  84.     if (k.find(s) != string::npos)
  85.       res++;
  86.   }
  87.   cout << res << el;
  88. }
  89.  
  90. int main()
  91. {
  92.   sasa();
  93.  
  94.   ll t = 1, i = 1;
  95.   // cin >> t;
  96.   while (t--)
  97.   {
  98.     // cout << "test #" << i << ":\n";
  99.     solve();
  100.     i++;
  101.     if (!t)
  102.       break;
  103.     // cout << "\n";
  104.   }
  105.  
  106.   return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement