hdu5105Math Problem(分類討論)
題目鏈接:
huangjing
題目:
思路:
給出的是一個方程,首先討論最高項系數。
1:a==0&& b==0 那麼函數就是線性的,直接比較端點即可。
2 a==0&&b!=0 那麼函數就是二次函數,直接算出特征值,然後比較端點值即可。。
3 a!=0 又有幾種情況,那麼當特征根 b*b-4*a*c<0 時 說明願函數是單調,直接比較端點值即可。。
當大於0的時候,直接求出兩個根,然後和端點值比較即可
ps:所有的特征根都要是有效的,即都要在[L,R]之間。。
題目:
Math Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 943 Accepted Submission(s): 250
Problem Description
Here has an function:
f(x)=|a?x3+b?x2+c?x+d|(L≤x≤R)
Please figure out the maximum result of f(x).
Input
Multiple test cases(less than 100). For each test case, there will be only 1 line contains 6 numbers a, b, c, d, L and R.
(?10≤a,b,c,d≤10,?100≤L≤R≤100)
Output
For each test case, print the answer that was rounded to 2 digits after decimal point in 1 line.
Sample Input
1.00 2.00 3.00 4.00 5.00 6.00
Sample Output
310.00
Source
BestCoder Round #18
Recommend
heyang | We have carefully selected several similar problems for you: 5106 5103 5102 5101 5100
Statistic | Submit | Discuss | Note
代碼:
#include
#include
#include
#include
#include