Statistics

Problem Statement for "WagonWheel"

Problem Statement

PROBLEM STATEMENT

In the movies, the wheels on a wagon frequently look like they are going the
wrong direction or as if they are not turning at all. In this case, it looks
like the wagon is sliding instead of rolling!  This is because we only see a
sequence of frames, 24 per second and the wheels are symmetrical.  If in
successive frames a wheel's appearance hasn't changed, we perceive the wheel as
sliding across the ground.

We have a wagon on which the front and back wheels may be different sizes.  We
are going to make a movie using this wagon, and want to tell the driver the
maximum number of feet per second that he is allowed to drive. We will choose
that number as big as possible subject to the requirement that the wagon must
never appear to be sliding on all its wheels at the same time. Create a class
WagonWheel that contains the method safeSpeed that takes circumferences and
number of spokes of the 2 different wheels as inputs and returns the highest
speed which is safe and for which all slower speeds are also safe from sliding.

DEFINITION
Class: WagonWheel 
Method: safeSpeed
Parameters: int,int,int,int   
Returns: int
Method Signature (be sure your method is public):  int safeSpeed(int c1, int
n1, int c2, int n2);

ci is the circumference of the i-th wheel in inches and ni is the number of
spokes in the i-th wheel. Return the speed in feet per second. 

NOTES
- do not return a speed at which both wheels appear to be sliding
- there are 24 frames per second
- the spokes are evenly distributed around each wheel
- there are 12 inches in a foot

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- c1 is between 3 and 1000 inclusive
- c2 is between 3 and 1000 inclusive
- n1 is between 3 and 30 inclusive
- n2 is between 3 and 30 inclusive

EXAMPLES 

1) 200,4,200,4: return 99

All the wheels are identical and will appear to slide when a multiple of 90
degrees of rotation occurs between frames.  This happens when the wagon moves
200/4 = 50 inches in 1/24 of a second so at a speed of 1200 inches per second.
Every speed LESS than 1200 inches per second is safe. So return the biggest
value less than 100 (feet per second).
  
2) 200,4,400,3: return 799

Wheel 1 slides at speeds of 1200,2400,3600,... inches per second.  Wheel 2
slides at speeds of 3200,6400,9600,... inches per second.  The slowest speed at
which both slide is at 9600 inches per second = 800 feet per second.

3) 7,3,5,3: return 23

At 7/3 inches per frame and multiples of that rate the first wheel slides.  At
multiples of 5/3 inches per frame the second wheel slides. So 35/3 inches per
frame is the lowest speed at which both slide.  That converts to 70/3 feet per
second, so 23 is safe.

4) 1000,30,999,27: return 7399

5) 5,30,6,23: return 11

Definition

Class:
WagonWheel
Method:
safeSpeed
Parameters:
int, int, int, int
Returns:
int
Method signature:
int safeSpeed(int param0, int param1, int param2, int param3)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: