Submission #1961699


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  vector<bool> prime(100005,true);
  prime[0]=prime[1]=false;
  rep(i,100005)if(prime[i])
    for(j=2;i*j<100005;j++)prime[i*j]=false;
  vi p(100005,0);
  rep(i,100005)if(i%2==1 && prime[i] && prime[(i+1)/2])p[i]++;
  rep(i,100000)p[i+1]+=p[i];
  int n;
  cin>>n;
  rep(i,n){
    int l,r;
    cin>>l>>r;
    cout<<p[r]-p[l-1]<<endl;
  }
}

Submission Info

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

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 400 / 400 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 218 ms 1024 KB
02.txt 220 ms 1024 KB
03.txt 217 ms 1024 KB
04.txt 219 ms 1024 KB
05.txt 205 ms 1024 KB
06.txt 211 ms 1024 KB
07.txt 219 ms 896 KB
sample_01.txt 2 ms 640 KB
sample_02.txt 2 ms 640 KB
sample_03.txt 2 ms 640 KB