Submission #1923288


Source Code Expand

Copy
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    vector<bool> p(100001, true);
    p[0] = p[1] = false;
    for (int i = 2; i < 100001; ++i)
        if (p[i])
            for (int j = 2 * i; j < 100001; j += i)
                p[j] = false;
    vector<int> pref(100001);
    pref[0] = pref[1] = 0;
    for (int i = 2; i < 100001; ++i)
    {
        pref[i] = pref[i - 1];
        if (i % 2 == 1 && p[i] && p[(i + 1) / 2])
            ++pref[i];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        int L, P;
        cin >> L >> P;
        cout << pref[P] - pref[L - 1] << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task D - 2017-like Number
User ArturSocha
Language C++14 (GCC 5.4.1)
Score 400
Code Size 719 Byte
Status AC
Exec Time 169 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 167 ms 1024 KB
02.txt AC 167 ms 1024 KB
03.txt AC 167 ms 1024 KB
04.txt AC 167 ms 1024 KB
05.txt AC 165 ms 1024 KB
06.txt AC 166 ms 1024 KB
07.txt AC 169 ms 896 KB
sample_01.txt AC 2 ms 640 KB
sample_02.txt AC 2 ms 640 KB
sample_03.txt AC 2 ms 640 KB