F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

GTW likes math

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1438    Accepted Submission(s): 644


Problem Description
After attending the class given by Jin Longyu, who is a specially-graded teacher of Mathematics, GTW started to solve problems in a book titled ˇ°From Independent Recruitment to Olympiadˇ±. Nevertheless, there are too many problems in the book yet GTW had a sheer number of things to do, such as dawdling away his time with his young girl. Thus, he asked you to solve these problems.

In each problem, you will be given a function whose form is like $f(x)=ax ^ 2 + bx + c$. Your assignment is to find the maximum value and the minimum value in the integer domain $[l, r]$.
 

Input
The first line of the input file is an integer $T$, indicating the number of test cases. ($T\leq 1000$)

In the following $T$ lines, each line indicates a test case, containing 5 integers, $a, b, c, l, r$. ($|a|, |b|, |c|\leq 100, |l|\leq |r|\leq 100$), whose meanings are given above.
 

Output
In each line of the output file, there should be exactly two integers, $max$ and $min$, indicating the maximum value and the minimum value of the given function in the integer domain $[l, r]$, respectively, of the test case respectively.
 

Sample Input
1 1 1 1 1 3
 

Sample Output
13 3
 

Hint
$f_1=3,f_2=7,f_3=13,max=13,min=3$
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 08:55:21, Gzip enabled