[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)