Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace __gnu_pbds;
- #define T \
- ll rrr; \
- cin >> rrr; \
- for (ll w1 = 0; w1 < rrr; w1++)
- #define cin(vec, a) for (ll i = 0; i < a && cin >> vec[i]; i++)
- #define cout(vec, a) for (ll i = 0; i < a && cout << vec[i] << " "; i++)
- #define MOD 1000000007
- #define PI 3.14159265
- #define ceil(a, b) ((a / b) + (a % b ? 1 : 0))
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #include <iostream>
- #define INF 1e9
- #define mod 1000000007
- #include <string>
- #define el '\n'
- #define sp ' '
- #define loop(n) for (int i = 0; i < n; i++)
- typedef long long ll;
- #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
- #define multi_ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
- template <typename O = int>
- istream &operator>>(istream &in, vector<O> &v)
- {
- for (auto &x : v)
- in >> x;
- return in;
- }
- template <typename O = int>
- ostream &operator<<(ostream &out, const vector<O> &v)
- {
- for (const O &x : v)
- out << x << ' ';
- return out;
- }
- void sasa()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input4.txt", "r", stdin), freopen("output4.txt", "w", stdout);
- #endif
- }
- ///////////////////////////////////////// code //////////////////////////////////////////////////////////////////////////
- vector<ll> primes;
- vector<bool> is_prime(1000001, true);
- void sieve()
- {
- is_prime[0] = is_prime[1] = false;
- for (ll i = 2; i * i <= 1000000; i++)
- {
- if (is_prime[i])
- {
- for (ll j = i * i; j <= 1000000; j += i)
- {
- is_prime[j] = false;
- }
- }
- }
- for (ll i = 2; i <= 1000000; i++)
- {
- if (is_prime[i])
- primes.push_back(i);
- }
- }
- void solve()
- {
- ll l, r, res = 0;
- string s;
- cin >> l >> r;
- cin >> s;
- l--;
- r--;
- sieve();
- //cout << primes.size() << el;
- for (int i = l; i <= r; i++)
- {
- string k = to_string(primes[i]);
- if (k.find(s) != string::npos)
- res++;
- }
- cout << res << el;
- }
- int main()
- {
- sasa();
- ll t = 1, i = 1;
- // cin >> t;
- while (t--)
- {
- // cout << "test #" << i << ":\n";
- solve();
- i++;
- if (!t)
- break;
- // cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement