QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#96281 | #2919. Subprime | Abdelrahman_ahmed7# | TL | 0ms | 0kb | C++17 | 1.4kb | 2023-04-13 18:41:00 | 2023-04-13 18:41:03 |
Judging History
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);
}
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
1 10000 389