Problem 6

All submissions for this problem are available.
Young Andrew has just learned about quadratic equations.
He was quite amazed by the fact that their solutions could look like (5+sqrt(3))/4,
so he wants to dig into this issue.
More specifically, given five numbers x, y, d, z and k, he wants to find the number of equations a*t2+b*t+c=0,
such that (x+y*sqrt(d))/z is a solution of the equation(i.e., when substituting it for t the equation holds.
a, b and c are integers, k <= a, b, c <= k.
Notice that the equations he's looking for are not necessarily quadratic, i.e., a is allowed to be zero, as is b and/or c.
Given five numbers x, y, d, z and k.
Input
The first line of input specifies the number of test cases m followed by m test cases.(1<=t<=20)
Each test case contains the values of x,y,z(1000<=x,y,z<=1000),d(1<=d<=1000)and k(0<=k<=1000000),
all seperated by spaces.
Output
Output is a single line which is to find the number of equations
a*t2+b*t+c=0 such that (x+y*sqrt(d))/z is a solution of the equation.
Examples
Input 1 5 1 3 4 30 Output 3 The three possible equations are: 0*x2+0*x+0=0, 8*x220*x+11=0, 8*x2+20*x11=0.
Author:  admin 
Tags  admin 
Date Added:  21092009 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.4, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 