Poj 3300 Tour de France (simple question)

Source: Internet
Author: User

[Description]: By the drive ratio -- the ratio of the angular velocity of the pedals to that of the wheels -- isN:MWhereNIs the number of teeth on the rear sprocket andMIs the number of teeth on the front sprocket. Two drive ratiosD1 <D2 are adjacent if there is no other drive ratioD1 <D3 <D2.SpreadBetween a pair of drive ratiosD1 <D2 is their quotient:D2?D1. you are to compute the maximum spread between two adjacent drive ratios achieved by a special pair of front and rear clusters. we can know that this ratios is equal to N/m, and then D (from 1 ...... N) is the value of every ratios, and now let's calculate the maximum di/d (I-1) value.

[Analysis]: Some questions are like this. As long as we understand the meaning of the question, we can quickly get rid of it. But if we do not understand the meaning of the question, we will ......

Code from: http://www.cnblogs.com/eric-blog/archive/2011/06/01/2067441.html

//184K 16Ms#include <cstdio>#include <algorithm> using namespace std; float ratio[100];int f,r;float front[10],rear[10];float max_ratio;int index; int main(){    while(scanf("%d",&f)!=EOF && f)    {        scanf("%d",&r);        for(int i=0; i<f; i++)            scanf("%f",&front[i]);        for(int i=0; i<r; i++)            scanf("%f",&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;}


Poj 3300 Tour de France (simple question)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.