标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 942 Accepted Submission(s): 426
#include<stdio.h> #include<string.h> #include<string> #include<math.h> #include<algorithm> #define LL long long #define PI atan(1.0)*4 #define DD double #define MAX 110 #define mod 10007 #define dian 1.000000011 #define INF 0x3f3f3f using namespace std; int main() { int t,Min,Max,i,j; int a,b,c,l,r,ans; scanf("%d",&t); while(t--) { scanf("%d%d%d%d%d",&a,&b,&c,&l,&r); ans=0;Max=-INF; Min=INF; if(l>=0) //区间内全是正数 { for(i=l;i<=r;i++) { ans=a*i*i+b*i+c; Max=max(Max,ans); Min=min(Min,ans); } } else { //printf("%d*\n",abs(l)); if(r>=0) //区间内有负有正 { for(i=1;i<=abs(l);i++) { j=0-i; //printf("%d*\n",j); ans=a*j*j+b*j+c; Max=max(Max,ans); Min=min(Min,ans); } for(i=0;i<=r;i++) { ans=a*i*i+b*i+c; Max=max(Max,ans); Min=min(Min,ans); } } else//区间内全是负数 { for(i=abs(r);i<=abs(l);i++) { j=0-i; //printf("%d*\n",j); ans=a*j*j+b*j+c; Max=max(Max,ans); Min=min(Min,ans); } } } printf("%d %d\n",Max,Min); } return 0; }
BestCoder Round #66 (div.2) hdu5592
标签:
原文地址:http://www.cnblogs.com/tonghao/p/5231956.html