hdoj 5595 GTW likes math 【水题】
来源:互联网 发布:淘宝屏蔽广告内容 编辑:程序博客网 时间:2024/05/16 04:20
GTW likes math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 357 Accepted Submission(s): 183
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$
题意:给定整数区间[l, r]问f(x) = a*x*x + b*x + c的最大值和最小值。
区间范围小,暴力即可。
AC代码:
#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <stack>#include <map>#include <set>#include <vector>#define INF 0x3f3f3f3f#define eps 1e-8#define MAXN (100000+1)#define MAXM (5000000000)#define Ri(a) scanf("%d", &a)#define Rl(a) scanf("%lld", &a)#define Rf(a) scanf("%lf", &a)#define Rs(a) scanf("%s", a)#define Pi(a) printf("%d\n", (a))#define Pf(a) printf("%.2lf\n", (a))#define Pl(a) printf("%lld\n", (a))#define Ps(a) printf("%s\n", (a))#define W(a) while(a--)#define CLR(a, b) memset(a, (b), sizeof(a))#define MOD 1000000007#define LL long long#define lson o<<1, l, mid#define rson o<<1|1, mid+1, r#define ll o<<1#define rr o<<1|1using namespace std;int main(){ int t; Ri(t); while(t--) { int a, b, c, l, r; Ri(a); Ri(b); Ri(c); Ri(l); Ri(r); int Min = INF, Max = -INF; for(int i = l; i <= r; i++) { int val = a*i*i + b*i + c; Min = min(Min, val); Max = max(Max, val); } printf("%d %d\n", Max, Min); } return 0;}
0 0
- hdoj 5595 GTW likes math 【水题】
- 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(简单数学,模拟)
- 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 【思维 】
- js 异步上传图片 限制图片的格式大小
- logback与Log4J的区别
- hihocoder #1141 : 二分·归并排序之逆序对
- unity5.x的bug
- 第十六周 项目一 验证算法(6) 堆排序
- hdoj 5595 GTW likes math 【水题】
- 第14周项目4(3)输出所有路径
- [宇宙与天文]灵魂星体投射
- 第十六周 项目一 (2) 插入排序之排序中输出每一趟的中间结果
- Service组件(本地、远程调用)详解
- Win8系统mscomctl.ocx缺失的解决方法 run-time error 339
- 第十六周实践项目2—大数据集上排序算法性能的体验
- Kindeditor 4.1.10 JSP Firefox 报上传错误
- 冒泡排序