please check my code for problem BROUL on spoj....i'm getting correct answers for all the test cases mentioned but still getting WA...
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
struct node{
long int i;
struct node *l;
}*start=NULL,*p2,*tmp;
int main()
{
long int p,b,p1,d,n,k;
while(1)
{
n=0;
scanf("%ld%ld%ld",&p,&b,&p1);
if((p==0)&&(b==0)&&(p1==0))
break;
else
{
d=p1-p;
d=abs(d);
if(d%b!=0)
n=0;
else
{
k=d/b;
if(k>=3)
n=k/3;
k=k%3;
if(k>0)
n++;
}
tmp=(struct node *)malloc(sizeof(struct node));
tmp->i=n;
tmp->l=NULL;
if(start==NULL)
start=tmp;
else
{
p2=start;
while(p2->l!=NULL)
p2=p2->l;
p2->l=tmp;
tmp->l=NULL;
}
}}
p2=start;
while(p2!=NULL)
{
if(p2->i==0)
printf("No accounting tablet");
else
printf("%ld",p2->i);
p2=p2->l;
printf("\n");
}
return 0;
}