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.
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 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.
Input 1 5 1 3 4 30 Output 3 The three possible equations are: 0*x2+0*x+0=0, 8*x2-20*x+11=0, -8*x2+20*x-11=0.
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.