博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3300 Tour de France(我的水题之路——车轮角速度最大)
阅读量:4068 次
发布时间:2019-05-25

本文共 2831 字,大约阅读时间需要 9 分钟。

Tour de France
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3704   Accepted: 1759

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 : 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 d< d2 are adjacent if there is no other drive ratio d< d< d2. The spread between a pair of drive ratios d< 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.

You may assume that no cluster has more than 10 sprockets and that no gear has fewer than 10 or more than 100 teeth.

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

Source

, 2007.7.14
山地自行车,有前轮和后轮,前轮有fn种驱动齿轮,后轮有rn种驱动齿轮,每种驱动齿轮上和链条结合的齿数不一样,前轮为fj(j=1,2,...fn),后轮为ri(i=1,2...rn),现在前后两个齿轮相结合工作的齿轮比例为dk = ri / fj,然后走到相邻的d1<d2,且没有d3使得d1<d3<d2,定义这时的spread为d2/d1。问fn种前驱齿轮和种后驱齿轮形成的spread的最大值为多少?
读入所有的ri、fj,然后计算出所有的dk,再对d进行从小到大排序,找到d[i+1] / d[i]的最大值。
注意点:
1)是多case题目,以0结束,注意初始化。
2)结果保留两位小数。
代码(1AC):
#include 
#include
#include
#include
using namespace std;int rear[15];int front[15];float dratio[300];int main(void){ int f, r; int i, j, k; float max, tmp; while (scanf("%d", &f), f != 0){ memset(dratio, 0, sizeof(dratio)); memset(rear, 0, sizeof(rear)); memset(front, 0, sizeof(front)); scanf("%d", &r); for (i = 0; i < f; i++){ scanf("%d", &front[i]); } for (i = k = 0, max = -1; i < r; i++){ scanf("%d", &rear[i]); for (j = 0; j < f; j++){ dratio[k++] = (float)rear[i] / (float)front[j]; } } sort(dratio, dratio+k); max = -1; for (i = 0; i < k - 1 ; i++){ tmp = dratio[i + 1] / dratio[i]; if (tmp > max){ max = tmp; } } printf("%.2f\n", max); } return 0;}

转载地址:http://oloji.baihongyu.com/

你可能感兴趣的文章
FTP 常见问题
查看>>
zookeeper单机集群安装
查看>>
do_generic_file_read()函数
查看>>
Python学习笔记之数据类型
查看>>
Python学习笔记之特点
查看>>
Python学习笔记之安装
查看>>
shell 快捷键
查看>>
VIM滚屏操作
查看>>
EMC 2014存储布局及十大新技术要点
查看>>
linux内核内存管理(zone_dma zone_normal zone_highmem)
查看>>
将file文件内容转成字符串
查看>>
循环队列---数据结构和算法
查看>>
优先级队列-数据结构和算法
查看>>
链接点--数据结构和算法
查看>>
servlet中请求转发(forword)与重定向(sendredirect)的区别
查看>>
Spring4的IoC和DI的区别
查看>>
springcloud 的eureka服务注册demo
查看>>
eureka-client.properties文件配置
查看>>
MODULE_DEVICE_TABLE的理解
查看>>
platform_device与platform_driver
查看>>