Submission #1925411


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define L 100001
long q;
vector < long> prim(L,0);
void init()
{
    vector < long > tmp(L,1);
    long i,j;
    for (i=2;i<=sqrt(L);i++)
        if (tmp[i])
            for (j=2*i;j<L;j+=i)
                tmp[j]=0;
    tmp[0]=tmp[1]=0;
    for (i=1;i<L;i+=2)
        if (tmp[i]&&tmp[(i+1)/2]) prim[i]=1;
    for (i=1;i<L;i++)
        prim[i]+=prim[i-1];
    for (i=1;i<L;i++)
        cout<<i<<":"<<prim[i]<<endl;
}
void solve()
{
    while(q--)
    {
        long l,r;
        scanf("%ld%ld",&l,&r);
        if (l==r&&prim[l-1]==prim[r]) printf("1\n");
        else printf("%ld\n",prim[r]-prim[l-1]);
    }
}
int main()
{
    init();
    while(~scanf("%ld",&q))
        solve();
}

Submission Info

Submission Time
Task D - 2017-like Number
User wahahawa
Language C++14 (GCC 5.4.1)
Score 0
Code Size 764 Byte
Status WA
Exec Time 193 ms
Memory 2816 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:27:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%ld%ld",&l,&r);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
WA × 3
WA × 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 WA 193 ms 2816 KB
02.txt WA 188 ms 2816 KB
03.txt WA 187 ms 2816 KB
04.txt WA 191 ms 2816 KB
05.txt WA 187 ms 2816 KB
06.txt WA 188 ms 2816 KB
07.txt WA 185 ms 2816 KB
sample_01.txt WA 162 ms 2816 KB
sample_02.txt WA 164 ms 2816 KB
sample_03.txt WA 163 ms 2816 KB