HDOJ--5595--GTW likes math
来源:互联网 发布:视频播放加速软件 编辑:程序博客网 时间:2024/06/07 01:54
GTW likes math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 963 Accepted Submission(s): 434
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 likef(x)=ax2+bx+c . Your assignment is to find the maximum value and the minimum value in the integer domain [l,r] .
In each problem, you will be given a function whose form is like
Input
The first line of the input file is an integer T , indicating the number of test cases. (T≤1000 )
In the followingT lines, each line indicates a test case, containing 5 integers, a,b,c,l,r . (|a|,|b|,|c|≤100,|l|≤|r|≤100 ), whose meanings are given above.
In the following
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
11 1 1 1 3
Sample Output
13 3Hint$f_1=3,f_2=7,f_3=13,max=13,min=3$
题目:给定函数a*x*x+b*x+c,让你求这个函数在【l,r】区间内的最大值和最小值。
思路:暴力,无脑。我的天啊,好可怕。
#include<stdio.h>#include<string.h>#include<algorithm>#define INF 0x3f3f3f3fusing namespace std;int main(){int T;scanf("%d",&T);while(T--){long long a,b,c,l,r;scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&l,&r);long long MAX=-INF,MIN=INF;for(int i=l;i<=r;i++){long long key=a*i*i+b*i+c;MAX=max(MAX,key);MIN=min(MIN,key);}printf("%lld %lld\n",MAX,MIN);}}
ac代码:
0 0
- HDOJ--5595--GTW likes math
- hdoj-5595-GTW likes math
- hdoj GTW likes math 5595 (暴力)
- HDOJ 5595 GTW likes math 【二次函数】
- HDOJ 5595 GTW likes math (暴力)
- hdoj 5595 GTW likes math 【水题】
- HDOJ 5595-GTW likes math【数学】
- HDOJ 5595 GTW likes math(简单数学,模拟)
- HDU 5595 GTW likes math
- Hdu 5595 GTW likes math
- HDU 5595 GTW likes math
- 杭电5595 GTW likes math
- HDU5595:GTW likes math
- HDU 5595/BC 66A GTW likes math
- hdoj-【5597 GTW likes function】
- BestCoder Round #66 GTW likes math
- HDOJ 5596 GTW likes gt(巧解)
- HDOJ 5596 GTW likes gt 【思维 】
- 关于定义的alert和confirm出现闪退问题
- TextField控件详解
- (二)JFreeChar 柱状图
- javabean中的boolean 类型属性命名
- 理解一下ORACLE数据库
- HDOJ--5595--GTW likes math
- (三)JFreeChar 饼状图
- UIBezierPath精讲
- iOS 过渡动画的实现
- 添加zabbix客户端
- Web Browse Process
- Xp 下使用 Fiddler 抓取android手机包
- ADB命令的使用
- 控制应用访问权限