My code pass in all this test and still WA
What is the prob?
[c]
#include <stdio.h>
int v[40000]; /* only to mark prime numbers */
int prime [40000]; /* prime numbers */
int p[40]; /* to print */
int main (void)
{
int i,j,k,tam,x,y,tmp,tamp,diff,t;
/* mark prime */
for (i=0;i<35000;i++)
v[i]=1;
v[1]=0;
v[0]=0;
for (i=2;i<35000;i++)
{
if (v[i]==1)
for (j=i*2;j<35000;j+=i)
v[j]=0;
}
tam = 0;
/* put the prims in primes */
for (i=0;i<35000;i++)
{
if (v[i])
{
prime[tam]=i;
tam++;
}
}
/* read input */
while (scanf("%d %d",&x,&y) == 2)
{
if (y<x) /* swap */
{
i=x; x=y; y=i;
}
i=0;
while (prime[i]<x) i++; /* jump to first */
tamp = 0;
diff = -1;
/* print sequence */
for (;prime[i]<=y;i++)
{
if (tamp == 0)
{
p[tamp]=prime[i];
tamp++;
}
else if (tamp == 1)
{
diff = prime[i]-p[0];
p[tamp] = prime[i];
tamp++;
}
else if (tamp == 2)
{
if (prime[i]-p[1]==diff)
{
p[tamp] = prime[i];
tamp++;
}
else
{
diff=-1;
p[0] = p[1];
i--;
tamp=1;
}
}
else if (tamp>=3)
{
if (prime[i]-p[tamp-1]==diff)
{
p[tamp] = prime[i];
tamp++;
}
else
{
if (!(prime[i-(tamp+1)] < x && p[0]-prime[i-(tamp+1)] == diff))
{
for (j=0;j<tamp;j++)
{
if (j==0) printf("%d",p[j]);
else printf(" %d",p[j]);
}
printf("\n");
}
diff=-1;
p[0] = p[tamp-1];
tamp=1;
i--;
}
}
}
/* if there is one more to be print */
if (tamp>=3)
{
if (prime[i]-p[tamp-1]!=diff)
{
if (!(prime[i-(tamp+1)] < x && p[0]-prime[i-(tamp+1)] == diff))
{
for (j=0;j<tamp;j++)
{
if (j==0) printf("%d",p[j]);
else printf(" %d",p[j]);
}
printf("\n");
}
}
}
}
return 0;
}
[/c]
thx