TSECAU02 - Editorial

Problem Link:

Practice

Contest

Author: tseccodecell

DIFFICULTY:

Cakewalk

PREREQUISITES:

Simple arithmetic operations

PROBLEM:

Given circumference of two wheels X and Y, and the difference is distance travelled by them D for the same number of revolutions, find the number of revolutions.

QUICK EXPLANATION:

Use the formula R=(D / abs(X-Y)) where abs is absolute value or modulus.

EXPLANATION:

Let distance travelled by wheel A and B be D1 and D2 respectively. Then D1=XR and D2=YR.
But we know that positive difference of D1 and D2 is D.

Therefore,

D=abs(D1-D2)

D=abs(X*R-Y*R)

D=R*abs(X-Y)

R=D/abs(X-Y)

SOLUTION:

https://ideone.com/lfmXHp