Exemplo n.º 1
0
int main()
{
    int i,k,l,flag;
    char K[105];
    freopen("poj2635.txt","r",stdin);
    freopen("poj2635ans.txt","w",stdout);
    GetPrimeList();
    while (scanf("%s%d",K,&l) && l)
    {
        memset(num,0,sizeof(num));
        cnt=0;k=1;
        for (i=strlen(K)-1;i>=0;i--)
        {
       	    if (k==1000000000)
       	    {
   	        k=1;
   	        cnt++;
       	    }
       	    num[cnt]+=(K[i]-'0')*k;
       	    k*=10;
        }
        flag=0;
        for (i=0;prime[i]<l;i++) 
	    if (MOD(prime[i])==0)
            {
       	        flag=1;
       	        break;
            }
        if (flag) printf("BAD %d\n",prime[i]);
        else printf("GOOD\n");
    }
    return 0;
}
Exemplo n.º 2
0
int GetTheCountOfCircularPrimesBelow1000000()
	{
	primeCount = GetPrimeList(limit, primeList);

	int result = 4;
	for(int i = 4; i < primeCount; ++i)
		if(IsRotatePrime(primeList[i]))
			++result;

	return result;
	}
Exemplo n.º 3
0
int GetThePrimeBelow1000000CanBeWrittenAsTheSumOfTheMostConsecutivePrimes()
	{
	int* buffer = new int[COUNT];
	int realCount = GetPrimeList(COUNT, buffer);
	int result = 0, maxLen = 0;

	for(int i = 0; i < realCount - 1; ++i)
		{
		buffer[i + 1] += buffer[i];
		if(buffer[i + 1] >= COUNT)
			{
			realCount = i;
			break;
			}
		}
	for(int i = realCount; i >= 0; --i)
		{
		int temp = buffer[i];
		if(IsPrime(temp))
			{
			if(i > maxLen)
				{
				maxLen = i;
				result = temp;
				}
			}
		else
			for(int j = 0; j < realCount; ++j)
				{
				if(IsPrime(temp - buffer[j]))
					{
					if(i - j - 1 > maxLen)
						{
						maxLen = i - j - 1;
						result = temp - buffer[j];
						}
					}
				}
		}
	delete []buffer;
	return result;
	}