ZCMU—1233
来源:互联网 发布:sf6微水测试仪数据 编辑:程序博客网 时间:2024/05/05 02:58
1233: Tour de France
Time Limit: 1 Sec Memory Limit: 128 MB[Submit][Status][Web Board]
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 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.
You may assume that no cluster has more than 10 sprockets and that no gear has fewer than 10 or more than 100 teeth.
For each test case, output the maximum spread rounded to two decimal places.
Input
Please Input Input Here
Output
Please Input Output Here
Sample Input
Sample Output
【分析】
#include <stdio.h>#include <algorithm>using namespace std;double f[100];double a[100],b[100];int len,n,m;int main(){ while(~scanf("%d",&n) && n) { scanf("%d",&m); for(int i=0;i<n;i++) scanf("%lf",&a[i]); for(int i=0;i<m;i++) scanf("%lf",&b[i]); int len=0; for(int i=0;i<m;i++) for(int j=0;j<n;j++) f[len++]=b[i]/a[j]; sort(f,f+len); double ans=0.0;for(int i=0;i<len-1;i++) ans=max(ans,f[i+1]/f[i]); printf("%.2f\n",ans); } return 0;}
- ZCMU—1233
- ZCMU—1678
- ZCMU—1605
- ZCMU—1067
- ZCMU—1607
- ZCMU—1069
- ZCMU—1611
- ZCMU—1606
- ZCMU—1774
- ZCMU—1766
- ZCMU—1752
- ZCMU—1724
- ZCMU—1623
- ZCMU—1689
- ZCMU—1667
- ZCMU—1639
- ZCMU—1668
- ZCMU—1540
- (十六)文件操作——chmod函数的介绍和使用
- delete 和 delete[]
- Hdu 5248 序列变换【二分+贪心】
- 水仙数问题详解
- Linux教程——sed编辑器使用实例
- ZCMU—1233
- Windows 如何在cmd命令行中查看、修改、删除与添加环境变量
- 二叉树的分层遍历的汇总
- Book6-Unit1
- 2216: [Poi2011]Lightning Conductor
- Book6-Unit2
- 变量在内存中的区域
- Book6-Unit3
- ubuntu服务器版本安装ftp