Submission #2543807
Source Code Expand
#include <iostream> #include <math.h> using namespace std; const int MAXSANG = 100000; int snt[MAXSANG+1]; void sangnt() { long i,j; for (i=1; i<=MAXSANG; i++) snt[i]=1; snt[1]=0; i=2; while (i<=sqrt(MAXSANG)) { while (snt[i]==0) i++; for (j=2; j<=MAXSANG/i; j++) snt[i*j]=0; i++; } } int main() { sangnt(); int f[100005]; f[2]=0; for(int i=3;i<=100000;i++){ if((snt[i])&&(snt[(i+1)/2])) f[i]=f[i-1]+1; else f[i]=f[i-1]; } int q; cin>>q; for(int i=1;i<=q;i++){ int l,r; cin>>l>>r; cout<<f[r]-f[l-1]<<endl; } }
Submission Info
Submission Time | |
---|---|
Task | D - 2017-like Number |
User | PINKUN |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 743 Byte |
Status | AC |
Exec Time | 229 ms |
Memory | 1408 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
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 | 228 ms | 1408 KB |
02.txt | AC | 228 ms | 1408 KB |
03.txt | AC | 225 ms | 1408 KB |
04.txt | AC | 229 ms | 1408 KB |
05.txt | AC | 211 ms | 1408 KB |
06.txt | AC | 225 ms | 1408 KB |
07.txt | AC | 226 ms | 1280 KB |
sample_01.txt | AC | 2 ms | 1024 KB |
sample_02.txt | AC | 2 ms | 1024 KB |
sample_03.txt | AC | 2 ms | 1024 KB |