hdu 5595 Math

来源:互联网 发布:数据库索引设计与优化 编辑:程序博客网 时间:2024/04/28 21:43

传送门:
http://acm.hdu.edu.cn/showproblem.php?pid=5595

大sb题,暴力就可以过,可是我当时却脑残的写了分类讨论,一直wrong
立个flag!!!
注意最小值可能是负数!!!

#include<bits/stdc++.h>using namespace std;int t,a,b,c,l,r;const int inf=0x3f3f3f3f;int cal(int n){    return a*n*n+b*n+c;}int main(){    cin>>t;    while(t--){        scanf("%d%d%d%d%d",&a,&b,&c,&l,&r);int maxx=-inf;        int minn=1e9+10;        for(int i=l;i<=r;i++){            if(cal(i)>maxx){                maxx=cal(i);            }            minn=min(minn,cal(i));        }        printf("%d %d\n",maxx,minn);    }    return 0;}
0 0