QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#101297#2919. Subprimemen3mWA 7ms4180kbC++231.0kb2023-04-29 07:44:002023-04-29 07:44:04

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-29 07:44:04]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4180kb
  • [2023-04-29 07:44:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define int long long int
const int N = 1e6+5, MOD = 1e9 + 7; // 

#define nl '\n'
#define rv return void
#define Tests int test_cases; cin >> test_cases; for(int tc=1; tc<=test_cases; tc++)
#define EidMubarak ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

vector<bool> prime(N, true);
vector<int> primes;

void sieve() {
    prime[0] = prime[1] = false;
    for (int p = 2; p <= N / p; p++) {
        if (prime[p]) {
            for (int i = p * p; i < N; i += p) {
                prime[i] = false;
            }
        }
    }
    for (int i = 2; i < N; i++) {
        if (prime[i]) {
            primes.emplace_back(i);
        }
    }
}

string s, t;

bool can(int x) {
    t = to_string(x);
    return (t.find(s) != -1);
}

signed main() {
    EidMubarak
    // y3ni_mht3dee4();
    sieve();
    int l, r, ans = 0;
    cin >> l >> r >> s;
    for (int i = l - 1; i < r; i++)
        if (can(primes[i]))
            ans++;
    cout << ans << nl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 4180kb

input:

1 10000
389

output:

45

result:

ok single line: '45'

Test #2:

score: 0
Accepted
time: 4ms
memory: 4036kb

input:

1 100
8

output:

8

result:

ok single line: '8'

Test #3:

score: 0
Accepted
time: 7ms
memory: 4132kb

input:

8000 9000
395

output:

0

result:

ok single line: '0'

Test #4:

score: -100
Wrong Answer
time: 5ms
memory: 4052kb

input:

50000 80000
572

output:

61

result:

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