QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96281#2919. SubprimeAbdelrahman_ahmed7#TL 0ms0kbC++171.4kb2023-04-13 18:41:002023-04-13 18:41:03

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-13 18:41:03]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-04-13 18:41:00]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define el '\n'
#define all(a) a.begin(),a.end()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<typename T>

using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll N=1e13+5,mod=1e9+7;
string str;
ll counter = 0;
ll ans = 0;
ll l , r;

map<ll,ll> is_not_prime;

bool is_sub(string s1)
{
    if (str.size() > s1.size()) return true;
    if (s1.find(str) != string::npos)
    {
        return false;
    }
    return true;
}
void sieve()
{
    for (ll i = 2 ; i * i<= N ; i ++)
    {
        if (!is_not_prime[i])
        {

            counter++;
            if (l <= counter && counter <= r)
            {
//                cout << i << el;
                if (!is_sub(to_string(i))){ans++;}
            }
            if (counter == r)
            {
                return;
            }
            for (ll j = i + i ; j * j <= N ; j += i )
            {
                is_not_prime[j] = true;
            }
        }
    }

}

void solve(ll t) {


    cin >> l >> r;
    cin >> str;
    sieve();
    cout << ans;

}
int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    ll t;
    //cin >> t;
    t = 1;
    for (ll i = 0 ; i < t ; i ++)
    {
        solve(i);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1 10000
389

output:


result: