QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#98790#2919. SubprimesamynagyWA 4ms5348kbC++141.3kb2023-04-20 06:03:062023-04-20 06:03:09

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-20 06:03:09]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:5348kb
  • [2023-04-20 06:03:06]
  • 提交

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'