Growling Gears
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11587
G Growling Gears
The Best Acceleration Production Company specializes in multi-gear engines. The performance
of an engine in a certain gear, measured in the amount of torque produced, is not constant:
the amount of torque depends on the RPM of the engine. This relationship can be described
using a torque-RPM curve.
RPM
Torque
Gear 1
Gear 2
The torque-RPM curve of the gears given in the second sample input.
The second gear can produce the highest torque.
For the latest line of engines, the torque-RPM curve of all gears in the engine is a parabola
of the form T = −aR2 + bR + c, where R is the RPM of the engine, and T is the resulting
torque.
Given the parabolas describing all gears in an engine, determine the gear in which the
highest torque is produced. The first gear is gear 1, the second gear is gear 2, etc. There will
be only one gear that produces the highest torque: all test cases are such that the maximum
torque is at least 1 higher than the maximum torque in all the other gears.
Input
On the first line one positive number: the number of test cases, at most 100. After that per test
case:
• one line with a single integer n (1 ≤ n ≤ 10): the number of gears in the engine.
• n lines, each with three space-separated integers a, b and c (1 ≤ a, b, c ≤ 10 000): the
parameters of the parabola T = −aR2 +bR+c describing the torque-RPM curve of each
engine.
Output
Per test case:
• one line with a single integer: the gear in which the maximum torque is generated.14 Problem G: Growling Gears
Sample in- and output
Input Output
3
1
1 4 2
2
3 126 1400
2 152 208
2
3 127 1400
2 154 208
1
2
2
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <malloc.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define MAX 999999999
#define LL long long
#define M 6666666
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int a,b,c,n,i,s[];
scanf("%d",&n);
for(i=;i<=n;i++)
{
scanf("%d%d%d",&a,&b,&c);
s[i]=(*(-*a)*c-b*b)/(*((-)*a));
}
int max=,g;
for(i=;i<=n;i++)
{
//printf("s=%d\n",s[i]);
if(s[i]>max)
{
g=i;
max=s[i];
}
}
printf("%d\n",g); }
return ;
}
Growling Gears的更多相关文章
- 【模拟】BAPC2014 G Growling Gears (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 计蒜客 28317.Growling Gears-一元二次方程的顶点公式 (Benelux Algorithm Programming Contest 2014 Final ACM-ICPC Asia Training League 暑假第一阶段第二场 G)
G. Growling Gears 传送门 此题为签到题,直接中学的数学知识点,一元二次方程的顶点公式(-b/2*a,(4*a*c-b*b)/4*a):直接就可以得到结果. 代码: #include& ...
- ACM 第十七天
暑期热身赛 BAPC 2014 The 2014 Benelux Algorithm Programming Contest 题目网址:https://odzkskevi.qnssl.com/3655 ...
- Benelux Algorithm Programming Contest 2014 Final(第二场)
B:Button Bashing You recently acquired a new microwave, and noticed that it provides a large number ...
- error LNK2019: 无法解析的外部符号 ___glutInitWithExit@12,该符号在函数 _glutInit_ATEXIT_HACK@8 中被引用 1>GEARS.obj : er
转: http://blog.csdn.net/bill_ming/article/details/8150111 opengl的高级菜鸟问题 看了一本书<OpenGL三维图形系统开发与应用技术 ...
- xtu read problem training 3 B - Gears
Gears Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 3789 ...
- 2015-2016 ACM-ICPC Pacific Northwest Regional Contest (Div. 2)V - Gears
Problem V | limit 4 secondsGearsA set of gears is installed on the plane. You are given the center c ...
- 【分享】GEARS of DRAGOON 1+2【日文硬盘版】[带全CG存档&攻略+SSG改动+打开存档补丁]
冒险者们哟.寻找龙秘玉吧--! ninetail的最新作,是使用丰富多彩的技能·道具探索迷宫的3D迷宫RPG! 存在着骑士和神官的架空世界常见的职业为首的13种职业.超过数百种的道具的登场! 和伙伴一 ...
- 2014 Super Training #8 A Gears --并查集
题意: 有N个齿轮,三种操作1.操作L x y:把齿轮x,y链接,若x,y已经属于某个齿轮组中,则这两组也会合并.2.操作Q x y:询问x,y旋转方向是否相同(等价于齿轮x,y的相对距离的奇偶性). ...
随机推荐
- 关于NPC和NP-Hard问题
参考链接: 1. P.NP.NPC和NP-hard问题的理解 参考:<算法导论>
- DataNavigator之分页
前言 做客户端也有两个月了,先前做列表都没有分页,可能考虑数据也不是很多,昨天做了一个页面,考虑到了数据的问题,所以改为分页查询.因为也是第一次用dev,用哪个控件分页呢,还是要去搜一下,得出的事Da ...
- 解决使用 Composer 的时候提示输入 Token
Could not fetch https://api.github.com/repos/RobinHerbots/jquery.inputmask/contents/bower.json?ref=0 ...
- sql修改表结构、临时表应用
alter table dbo.P_ZPROMOTION_DOC_ITEMS_TEMP alter column MCRANK varchar(20); 方法一: use testdb --创建局部 ...
- MySQL之count(*)与count(id)效率比较(转)
优化总结: 1.任何情况下SELECT COUNT(*) FROM tablename是最优选择: 2.尽量减少SELECT COUNT(*) FROM tablename WHERE COL = ’ ...
- 干货:Web应用上线之前程序员应该了解的技术细节
[伯乐在线注]:<Web 应用上线前,程序员应考虑哪些技术细节呢?>这是 StackExchange 上面的一个经典问题贴. 最赞回复有 2200+ 顶,虽然大多数人可能都听过其中大部分内 ...
- CentOS添加RPMforge软件源
1.查看CentOS版本 cat /etc/redhat-release 2.查看系统位数 uname -i 3.下载rpm包 wget "rpm地址" CentOS 6: i68 ...
- Hibernate与数据库分表
数据库分片(shard)是一种在数据库的某些表变得特别大的时候采用的一种技术. 通过按照一定的维度将表切分,可以使该表在常用的检索中保持较高的效率,而那些不常用的记录则保存在低访问表中.比如:销售记录 ...
- mongodb MongoDB 聚合 group
MongoDB 聚合 MongoDB中聚合(aggregate)主要用于处理数据(诸如统计平均值,求和等),并返回计算后的数据结果.有点类似sql语句中的 count(*). 基本语法为:db.col ...
- matlab高斯模板生成,K是归一化系数,上面是一个半径200的高斯模板用来做MSR
R3=; F=zeros(*R3+,*R3+); sigma=R3/; r=; :*R3+ :*R3+ r=(x-R3)*(x-R3)+(y-R3)*(y-R3); ...