Growling Gears
2015-08-12 19:49
288 查看
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
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[15]; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d%d",&a,&b,&c); s[i]=(4*(-1*a)*c-b*b)/(4*((-1)*a)); } int max=0,g; for(i=1;i<=n;i++) { //printf("s=%d\n",s[i]); if(s[i]>max) { g=i; max=s[i]; } } printf("%d\n",g); } return 0; }
相关文章推荐
- cf 10D lcis 最长上升子序列+输出路径
- HYSBZ 1008 越狱 快速幂取模
- JavaScript基础学习之-JavaScript权威指南-第三章类型、值和变量
- JavaScript基础学习之-JavaScript权威指南-3.10变量作用域
- 欢迎使用CSDN-markdown编辑器
- Json.Net学习.集合序列化.
- Android学习之浅谈selector与Shape用法
- 1054. The Dominant Color (20)
- 它的斗争“和loser对话”短篇故事
- Json.Net学习(1) 实现简单的序列化和反序列化
- [HDU 4009] Transfer water 最小树形图
- 结合多线程、Socket的聊天小程序
- LTView
- C#使用lock锁定静态变量
- HTTPConnection与HTTPClient
- bfs 马的移动
- Telerk-asp.net 第三方控件之控件讲解(一)
- 长按弹出快捷菜单
- http://blog.sina.com.cn/s/blog_777a9ccb01013maj.html
- 【 D3.js 入门系列 --- 9.6 】 生产的包图