Sicily 1450. Tour de France
来源:互联网 发布:三步倒淘宝叫什么暗号 编辑:程序博客网 时间:2024/05/19 13:07
1450. Tour de France
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
A racing bicycle is driven by a chain connecting two sprockets. Sprockets are grouped into two clusters: the front cluster (typically consisting of 2 or 3 sprockets) and the rear cluster (typically consisting of between 5 and 10 sprockets). At any time the chain connects one of the front sprockets to one of the rear sprockets. The drive ratio -- the ratio of the angular velocity of the pedals to that of the wheels -- is n:m where n is the number of teeth on the rear sprocket and m is the number of teeth on the front sprocket. Two drive ratios d1<d2 are adjacent if there is no other drive ratio d1<d3<d2. The spread between a pair of drive ratios d1<d2 is their quotient: d2/d1. You are to compute the maximum spread between two adjacent drive ratios achieved by a particular pair of front and rear clusters.
Input
Input consists of several test cases, followed by a line containing 0. Each test case is specified by the following input:
- f: the number of sprockets in the front cluster;
- r: the number of sprockets in the rear cluster;
- f integers, each giving the number of teeth on one of the gears in the front cluster;
- r integers, each giving the number of teeth on one of the gears in the rear cluster.
Output
For each test case, output the maximum spread rounded to two decimal places.
Sample Input
2 440 5012 14 16 190
Sample Output
1.19
// Problem#: 1450// Submission#: 3311929// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <iostream>#include <vector>#include <algorithm>#include <stdio.h>#include <math.h>#include <string.h>#include <string>#include <queue>#include <set>#include <iomanip>using namespace std;int r[15];int f[15];int R, F;double d[150];int main() { std::cout.sync_with_stdio(false); string temp; while (1) { cin >> F; if (F == 0) break; cin >> R; for (int i = 0; i < F; i++) cin >> f[i]; for (int i = 0; i < R; i++) cin >> r[i]; for (int i = 0; i < R; i++) { for (int j = 0; j < F; j++) { d[i * F + j] = r[i] * 1.0 / f[j]; } } sort(d, d + R * F); double ans = -1; for (int i = 1; i < R * F; i++) if (d[i] != d[i - 1]) ans = max(ans, d[i] / d[i - 1]); cout << fixed << setprecision(2) << ans << endl; } return 0;}
- Sicily 1450. Tour de France
- poj 3300 Tour de France
- ZCMU-1233-Tour de France
- Tour de France - 法国大西南
- POJ 3300 Tour de France(简单题)
- POJ 3300 Tour de France 再想想
- POJ 3300 Tour de France(我的水题之路——车轮角速度最大)
- Tour de Flex
- Tour De Babel
- Tour De Babel
- [bzoj3060]Tour de Byteotia
- sicily 2382 Flowers Flourish from France
- Developer Connection: Tour de Flex
- BZOJ3060: [Poi2012]Tour de Byteotia
- BZOJ3060 [Poi2012]Tour de Byteotia
- 3060: [Poi2012]Tour de Byteotia
- BZOJ3060: [Poi2012]Tour de Byteotia
- 好东西!Tour de Flex component explorer
- LayoutInflater
- Sicily 1453. Conformity
- 第二周项目4-时间类
- 第二周上机时间项目3——时间类
- 自总结shell
- Sicily 1450. Tour de France
- poj 2251 Dungeon Master 【BFS】
- poj2873 Til the Cows Come Home
- linux之间文件传输(转)
- [译]【Storm入门指南】第四章 Spouts
- 面试题:C++有了malloc/free,为什么还需要new、delete?
- Linux系统下安装rz/sz命令及使用说明
- java模式之观察者模式
- 剑指offer(1) - 实现Singleton模式