BestCoder Round #66 1001
GTW likes math
Accepts: 472 Submissions: 2140
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 like f(x)=ax^2+bx+c. Your assignment is to find the maximum value and the minimum value in the integer domain [l,r].
The first line of the input file is an integer T, indicating the number of test cases. (T≤1000)
In the following TT 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 each line of the output file, there should be exactly two integers, maxmax and minmin, indicating the maximum value and the minimum value of the given function in the integer domain [l,r], respectively, of the test case respectively.
1
1 1 1 1 3
13 3
f1=3,f2=7,f3=13,max=13,min=3
某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学《从自主招生到竞赛》。然而书里的题目太多了,GTW还有很多事情要忙(比如把妹),于是他把那些题目交给了你。每一道题目会给你一个函数f(x)=ax^2+bx+cf(x)=ax2+bx+c,求这个函数在整数区间[l,r]之间的最值。
第一行一个整数T,表示数据组数。(T≤1000)
对于每一组数据,有一行,共五个整数a,b,c,l,r。(∣a∣≤100,∣b∣≤100,∣c∣≤100,∣l∣≤100,∣r∣≤100,l≤r)
对于每一组数据,共一行两个整数max,min,表示函数在整数区间[l,r]中的最大值和最小值。
1
1 1 1 1 2
7 3
f1=3,f2=7,最大值=7,最小值=3 没必要用什么公式了,一路从L计算到R 保存最大最小就好
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
int a,b,c;
int l,r;
int i,j;
int main()
{
int t;
cin>>t;
while(t--)
{
cin>>a>>b>>c>>l>>r;
int maxn=-inf,minn=inf;
for(i=l;i<=r;i++)
{
maxn=max(maxn,a*i*i+b*i+c);
minn=min(minn,a*i*i+b*i+c);
}
cout<<maxn<<" "<<minn<<endl;
}
return 0;
}
BestCoder Round #66 1001的更多相关文章
- 贪心 BestCoder Round #39 1001 Delete
题目传送门 /* 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少: 否则再在tot里减去多余的即为答案 用set容器也可以做,思路一样 */ # ...
- 暴力 BestCoder Round #41 1001 ZCC loves straight flush
题目传送门 /* m数组记录出现的花色和数值,按照数值每5个搜索,看看有几个已满足,剩下 5 - cnt需要替换 ╰· */ #include <cstdio> #include < ...
- 暴力 BestCoder Round #46 1001 YJC tricks time
题目传送门 /* 暴力:模拟枚举每一个时间的度数 详细解释:http://blog.csdn.net/enjoying_science/article/details/46759085 期末考结束第一 ...
- 字符串处理 BestCoder Round #43 1001 pog loves szh I
题目传送门 /* 字符串处理:是一道水题,但是WA了3次,要注意是没有加'\0'的字符串不要用%s输出,否则在多组测试时输出多余的字符 */ #include <cstdio> #incl ...
- BestCoder Round #75 1001 - King's Cake
Problem Description It is the king's birthday before the military parade . The ministers prepared a ...
- BestCoder Round #92 1001 Skip the Class —— 字典树 or map容器
题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=748&pid=1001 题解: 1.trie树 关 ...
- BestCoder Round #66 (div.2)B GTW likes gt
思路:一个O(n)O(n)的做法.我们发现b_1,b_2,...,b_xb1,b2,...,bx都加11就相当于b_{x+1},b_{x+2},...,b_nbx+1,bx+ ...
- BestCoder Round #61 1001 Numbers
Problem Description There are n numbers A1,A2....An{A}_{1},{A}_{2}....{A}_{n}A1,A2....An,yo ...
- BestCoder Round #66 (div.2)
构造 1002 GTW likes gt 题意:中文题面 分析:照着题解做的,我们可以倒着做,记一下最大值,如果遇到了修改操作,就把最大值减1,然后判断一下这个人会不会被消灭掉,然后再更新一下最大值. ...
随机推荐
- 什么是个CDN???CDN是干什么的??
1.什么是CDN??? CDN的全称是Content Delivery Network,即内容分发网络.其目的是通过在现有的Internet中增加一层新的网络架构,将网站的内容发布到最接近用户的网络& ...
- springmvc 初始化参数绑定(使用属性编辑器) 来处理类型转换问题
处理一种日期格式 处理器中的写法: index.jsp中的写法: 处理多种日期格式: 处理器的写法: 自定义的属性编辑器: index.jsp的写法:
- oracle 调整输出的列宽、行宽
调整列宽 col 列名 format a20 调整行宽 set linesize 150
- Maven学习笔记1-牛逼的POM文件
IDE:integrated development enterprise 集成开发环境: 一.pom文件 POM是项目对象模型(Project Object Model)的简称:maven世界中必须 ...
- POJ 1187 陨石的秘密 (线性DP)
题意: 公元11380年,一颗巨大的陨石坠落在南极.于是,灾难降临了,地球上出现了一系列反常的现象.当人们焦急万分的时候,一支中国科学家组成的南极考察队赶到了出事地点.经过一番侦察,科学家们发现陨石上 ...
- Luogu 4867 Gty的二逼妹子序列
BZOJ3809,是权限题. 我永远喜欢莫队. 先莫队一下移下左右指针,然后用一个数据结构维护一下区间$[a, b]$中的颜色的值,跟着指针移动一起修改修改,每一次$query$的时候就相当于查询一下 ...
- php 函数追踪扩展 phptrace
php 函数追踪扩展 phptrace 介绍 phptrace 是一个低开销的用于跟踪.分析 php 运行情况的工具. 它可以跟踪 php 在运行时的函数调用.请求信息.执行流程.并且提供有过滤器.统 ...
- <超越死亡:恩宠与勇气>节选
我有一副身体,但我并非自己的身体.我可以看见并感觉到我的身体,然而凡是可以被看见以及被感觉到的,并不是真正的观者.我的身体也许疲惫或兴奋,生病或健康,沉重或轻松,也可能焦虑或平静,但这与内在的真我全然 ...
- IOC与依赖注入
spring的核心思想是IOC和AOP,IOC-控制反转,是一个重要的面向对象编程的法则来消减计算机程序的耦合问题,控制反转一般分为两种类型,依赖注入和依赖查找,依赖什么?为什么需要依赖?注入什么?控 ...
- javascript window.showModalDialog不兼容goole解决方案
window.showModalDialog不兼容goole解决方案 一.弹框方案: 1.window.open; 2.window.showModalDialog; 3.div制作窗口:(本节忽略) ...