hdu 5595
来源:互联网 发布:网络打印共享器怎么用 编辑:程序博客网 时间:2024/03/29 03:22
GTW likes math
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 125 Accepted Submission(s): 76
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$
Source
BestCoder Round #66 (div.2)
//第一题还有一个罚时 真是low啊
#include <stdio.h>#include <algorithm>#include <string.h>using namespace std;int a,b,c;int f(int i){ return a*i*i+b*i+c;}int main(){ int t; scanf("%d",&t); while(t--) { int l,r; scanf("%d%d%d%d%d",&a,&b,&c,&l,&r); int ma,mi; ma=-10000000; mi=100000000; for(int i=l;i<=r;i++) { int t=f(i); if(t>ma) ma=t; if(t<mi) mi=t; } printf("%d %d\n",ma,mi); } return 0;}
0 0
- hdu 5595
- hdu 5595 Math
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- 在vs2010下编译OpenSSL
- ORA-06553:PLS-306:wrong number or types of arguments in call to ''
- 设置不自动弹出软键盘的最简洁解决方案
- VBS 改 IP(modify IP by VBS)
- HDU 1251 统计难题
- hdu 5595
- Java Notes-1
- java基础第八天——正则、集合与数组的区别
- java模拟异步消息机制
- Java Notes-2
- POJ 1062 迪杰斯特拉
- HDOJ 5595 GTW likes math(简单数学,模拟)
- Solve 0x80004005 issue, cannot access sharefolder under windows2012
- [hdoj试题]A+B for Input-Output Practice (VII)