paste bin

malic
C++
#include<cstdio>

const int MAXN=10009;
bool isPrime[MAXN];
void initPrime()
{
    int i,j;
    for(i=0;i<MAXN;i++)
        isPrime[i]=true;
    isPrime[0]=false;
    isPrime[1]=0;
    for(i=2;i<MAXN;i++)
    {
        if(isPrime[i]==true)
        for(j=i*i;j<MAXN;j+=i)
        {
            isPrime[j]=false;
        }
    }
}

int main(void)
{
    initPrime();
    int S,x,y;
    scanf("%d",&S);
    if(S%2==0)
    {
        x=S/2;
        y=S/2;
        while(isPrime[x]==false || isPrime[y]==false)
        {
            x+=1;
            y-=1;
        }
        printf("%d\n",x*y);
    }
    else
        printf("%d\n",2*(S-2));
    return 0;
}

2019 C1QA

fork this code