POJ 3300 Tour de France(简单题)

本文讨论了如何通过前齿和后齿的数量计算驱动比,并找出两个相邻驱动比之间的最大比率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【题意简述】:由The drive ratio -- the ratio of the angular velocity of the pedals to that of the wheels -- isn : m where n is the number of teeth on the rear sprocket andm 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 ratiosd1 < d2 is their quotient: d2d1. You are to compute the maximum spread between two adjacent drive ratios achieved by a particular pair of front and rear clusters.我们可以知道,这个ratios等于n/m,然后d(从1……n)就是每一个ratios的值,现在让我们求最大的di/d(i-1)的值。

【分析】:有些题就是这样,只要我们理解了题意就可以很快的A掉,但如果不理解题意,就……

代码借鉴:http://www.cnblogs.com/eric-blog/archive/2011/06/01/2067441.html

//236K 16Ms
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
 
using namespace std;
 
double ratio[100];
int f,r;
double front[10],rear[10];
double max_ratio;
int index;
 
int main()
{
    while(cin>>f,f)
    {
        cin>>r;
        for(int i=0; i<f; i++)
            cin>>front[i];
        for(int i=0; i<r; i++)
            cin>>rear[i];
        index=0;
        for(int i=0; i<r; i++)
        {
            for(int j=0; j<f; j++)
            {
                ratio[index++]=rear[i]/front[j];
            }
        }
        sort(ratio,ratio+index);
        for(int i=0; i<index-1; i++)
            ratio[i]=ratio[i+1]/ratio[i];
        max_ratio=0.0;
        for(int i=0; i<index-1; i++)
        {
            if(max_ratio<ratio[i])
                max_ratio=ratio[i];
        }
        printf("%.2f\n",max_ratio);
 
    }
    return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值