Submission #1925515


Source Code Expand

Copy
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int Q;
int V[100005];
bool sosuu[100005];
bool flag[100005];

void Sosuu(){
    for(int i=2;i<100005;++i){
        if(flag[i])continue;
        for(int j = 1;;++j){
            if(i*j > 100000)break;
            flag[i*j] = true;
        }
        sosuu[i] = true;
    }
}


signed main(){
    cin>>Q;
    Sosuu();
    for(int i=1;i<100005;++i){
        V[i] = V[i-1];
        if(sosuu[i] && sosuu[(i+1)/2])V[i]++;
    }
    for(int i=0;i<Q;++i){
        int l,r;
        cin>>l>>r;
        cout<<V[r]-V[l-1]<<endl;
    }
}

Submission Info

Submission Time
Task D - 2017-like Number
User koutarou
Language C++14 (GCC 5.4.1)
Score 400
Code Size 909 Byte
Status AC
Exec Time 222 ms
Memory 1664 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 217 ms 1536 KB
02.txt AC 221 ms 1536 KB
03.txt AC 222 ms 1536 KB
04.txt AC 220 ms 1536 KB
05.txt AC 207 ms 1664 KB
06.txt AC 213 ms 1664 KB
07.txt AC 220 ms 1536 KB
sample_01.txt AC 2 ms 1280 KB
sample_02.txt AC 2 ms 1280 KB
sample_03.txt AC 2 ms 1280 KB