... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 24, 2013

UVA-11934 :: Magic Formula

#include <iostream>
#include <cstdio>
using namespace std ;
int main ()
{
    int a ,b ,c ,d ,l ,t ,i ,x ,cnt ;

    while (scanf ("%d %d %d %d %d",&a,&b,&c,&d,&l) == 5)
    {
        if (a==0 && b==0 && c==0 && d==0 && l==0) break ;
        cnt=0 ;
        for (i=0 ; i<=l ; i++)
        {
            x= a*i*i + b*i + c ;
            if (x%d==0) cnt++;
        }

        cout<<cnt <<endl  ;
    }

    return 0 ;
}