#include<stdio.h>
int main()
{
long int test,a,b,c,d,l,i,j,fun,k;
while(scanf("%ld%ld%ld%ld%ld",&a,&b,&c,&d,&l)==5)
{
if((a==0)&&(b==0)&&(c==0)&&(d==0))
break;
fun=0;
k=0;
for(j=0;j<=l;j++)
{
fun=a*j*j+b*j+c;
if(fun%d==0)
k=k+1;
}
printf("%ld\n",k);
}
return 0;
}
int main()
{
long int test,a,b,c,d,l,i,j,fun,k;
while(scanf("%ld%ld%ld%ld%ld",&a,&b,&c,&d,&l)==5)
{
if((a==0)&&(b==0)&&(c==0)&&(d==0))
break;
fun=0;
k=0;
for(j=0;j<=l;j++)
{
fun=a*j*j+b*j+c;
if(fun%d==0)
k=k+1;
}
printf("%ld\n",k);
}
return 0;
}
No comments:
Post a Comment