Submission #3414877


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;
bool ip[SIZE];
int ps[SIZE];

int main()
{
	int Q;
	cin >> Q;
	int p=0;
	rep(i,0,SIZE)ip[i] = true;
	ip[0] = ip[1] = false;
	rep(i,2,SIZE){
		if(ip[i]) for(int j=2*i;j<=SIZE;j+=i) ip[j] = false;
	}
	int t = 0;
	rep(i,0,SIZE){
		if(ip[i] && ip[(i+1)/2])t++;
		ps[i] = t;
	}
	int l,r;
	rep(i,0,Q){
		cin >> l >> r;
		cout << ps[r]-ps[l-1] << endl;
	}

	return 0;
}

Submission Info

Submission Time
Task D - 2017-like Number
User lyosika50
Language C++14 (GCC 5.4.1)
Score 400
Code Size 646 Byte
Status AC
Exec Time 230 ms
Memory 1152 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 230 ms 1024 KB
02.txt AC 226 ms 1024 KB
03.txt AC 225 ms 1152 KB
04.txt AC 227 ms 1152 KB
05.txt AC 212 ms 1152 KB
06.txt AC 222 ms 1152 KB
07.txt AC 226 ms 1024 KB
sample_01.txt AC 2 ms 768 KB
sample_02.txt AC 2 ms 768 KB
sample_03.txt AC 2 ms 768 KB