QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#98790 | #2919. Subprime | samynagy | WA | 4ms | 5348kb | C++14 | 1.3kb | 2023-04-20 06:03:06 | 2023-04-20 06:03:09 |
Judging History
answer
#include <bits/stdc++.h>
/**
* author: samy nagy
*/
#define ll long long
#define all(vec) vec.begin(),vec.end()
#define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
#define rall(vec) vec.rbegin(),vec.rend()
#define fx(x) fixed<<setprecision(x)
#define endl "\n"
using namespace std;
const int N = 2e6+10;
vector<ll>primes ;
void sieve (){
bool vis[N+1];
::memset(vis , true , sizeof vis);
vis[0]=vis[1]=false;
for (int i = 2; i*i<=N; ++i) {
if(vis[i]){
primes.push_back(i);
for (int j = i*i; j <=N; j+=i) {
vis[j]=false;
}
}
}
}
bool ok (string num , string s ){
return num.find(s)!=-1;
}
void smsm ( ){
sieve();
string s ;
ll l , r ; cin>>l>>r>>s;
l--;
ll ans{};
for (int i = l; i <r && i<primes.size(); ++i) {
if(ok(to_string(primes[i]) , s ))++ans;
}
cout<<ans;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t=1;//cin>>t;
while (t--){
smsm();
cout<<"\n";
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 5348kb
input:
1 10000 389
output:
1
result:
wrong answer 1st lines differ - expected: '45', found: '1'