GTW likes math (BC 1001)

Source: Internet
Author: User

GTW likes Mathaccepts:472submissions:2140Time limit:2000/1000 MS (java/others)Memory limit:131072/131072 K (java/others)Problem description
One day, GTW listened to the maths teacher The Golden Dragon Fish class, began to do mathematics "from the independent enrollment to the competition". However, there are too many problems in the book, GTW still have a lot of things to be busy (such as the younger sister), so he gave the questions to you. Each topic will give
You a functionF (x) =AX2+BX+CF (x) =< Span class= "Mord" > < Span class= "Baseline-fix" > Ask this function in the integer interval Span class= "Katex" >[l,r]
Enter a description
The first line is an integer t that represents the number of data groups. (t≤1000t\leqT≤1000) for each set of data, there is a row, a total of five integers a,b,c,l,r. (∣a∣≤100,∣b∣≤100,∣c∣≤100,∣l∣≤100,∣r∣≤100,l<=r)       
Output description
For each set of data, a total of two integers max,min, representing the maximum and minimum values of the function in the integer interval  [l,r][l,r][l,R]. 
Input sample
11 1 1) 1 2
Output sample
9}
Hint
f1=3,f2=7f_1=3,f_2=7 f ? 1?? =3,f< Span class= "Vlist" >? 2?? =7, max = 7, min =3 
1#include <iostream>2#include <cstdio>3#include <algorithm>4 using namespacestd;5 intA,b,c,l,r;6 intFuncintx)7 {8     returnx*x*a+b*x+C;9 }Ten intMain () One { A     intt,i,j; -     intx, y; -Freopen ("In.txt","R", stdin); theCin>>T; -      while(t--) -     { -scanf"%d %d%d%d%d",&a,&b,&c,&l,&R); +         intmin=1000000, max=-1000000; -         if(a==0) +         { AMax=max (b*r+c,b*l+c); atMin=min (b*r+c,b*l+c); -         } -         Else -         { -              for(inti=l;i<=r;i++) -             { in                 intk=func (i); -                 //cout<<k<<endl; tomax=Max (max,k); +min=min (min,k); -             } the         } *printf"%d%d\n", max,min); $     }Panax Notoginseng}

< Span class= "base textstyle uncramped" >< Span class= "mpunct" > 


/span>

GTW likes math (BC 1001)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.