QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#876596#2919. SubprimemostafayWA 88ms48640kbC++141.3kb2025-01-31 03:36:182025-01-31 03:36:19

Judging History

This is the latest submission verdict.

  • [2025-01-31 03:36:19]
  • Judged
  • Verdict: WA
  • Time: 88ms
  • Memory: 48640kb
  • [2025-01-31 03:36:18]
  • Submitted

answer

#include <bits/stdc++.h>

#define fast ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define output freopen("~/output.txt","w",stdout);
#define input  freopen("~/input.txt","rt",stdin);
#define print(v) for(auto &ele:v)cout<<ele<<" "
#define cin(v) for(auto &ele:v)cin>>ele
#define pp pair<int ,int>
#define all(v) v.begin(),v.end()
#define rv(x) return void(x)
#define ln cout<<"\n";
#define yes cout<<"YES"
#define no cout<<"NO"
#define ll long long
#define vc vector
using namespace std;
int xd[4] = {-1, 0, 1, 0};//,-1,-1, 1, 1};
int yd[4] = {0, 1, 0, -1};//, 1,-1, 1,-1};

//===============================The solution===============================

vector<int> primes;
vector<int> is_prime;
int N = 1e7;

void sievo() {
    is_prime = vector<int>(N, 1);
    for (ll i = 2; i < N; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (ll j = i * i; j < N; j += i) {
                is_prime[j] = 0;
            }
        }
    }
}

void solve() {
    sievo();
    int l, h, cnt = 0;
    string p;
    cin >> l >> h >> p;
    for (int i = l; i <= h; ++i) {
        string is = to_string(primes[i]);
        if (is.find(p) != -1)cnt++;
    }
    cout << cnt;
}


int main() {
    fast
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
        ln
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 88ms
memory: 48640kb

input:

1 10000
389

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 73ms
memory: 48636kb

input:

1 100
8

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 74ms
memory: 48636kb

input:

8000 9000
395

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 79ms
memory: 48632kb

input:

50000 80000
572

output:

63

result:

ok single line: '63'

Test #5:

score: 0
Accepted
time: 74ms
memory: 48636kb

input:

90000 100000
9999

output:

5

result:

ok single line: '5'

Test #6:

score: 0
Accepted
time: 70ms
memory: 48640kb

input:

1 100000
37502

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 69ms
memory: 48612kb

input:

1 1000
000

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 72ms
memory: 48636kb

input:

4509 12345
9999

output:

4

result:

ok single line: '4'

Test #9:

score: -100
Wrong Answer
time: 74ms
memory: 48636kb

input:

1 1
2

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'