You are not logged in. Please login at www.codechef.com to post your questions!

×

# CLUSCL - Editorial

Author and Editorialist: Soumik Sarkar
Tester: Sarthak Manna

SIMPLE

Basic maths

# PROBLEM:

A 12 hour clock runs at $K$ times the rate of a correct clock. If initially at the start of day $1$ it shows the correct time find the day on which it shows the correct time for the $N^{th}$ time.

# EXPLANATION:

Let's call the correct clock $A$ and the useless one $B$. Let the time taken for one cycle of $A$ be designated as unit time. Let $\omega$ denote angular velocity is cycles per unit time, $\theta$ denote angular displacement in cycles, and $t$ denote time passed. We can say that

\begin{aligned} \omega_A &= 1 \\ \omega_B &= K \\ \theta_A &= \omega_A t\\ \theta_B &= \omega_B t\\ \end{aligned}

There are two cases to consider.

### Case $K < 1$:

As mentioned in the problem both $A$ and $B$ start off together. $B$ runs slower than $A$, so it will show the correct time again when it is exactly one cycle behind the $A$. If this time is $t$, then \begin{aligned} \theta_B &= \theta_A - 1 \\ \implies \omega_B t &= \omega_A t -1 \\ \implies K t &= t -1 \\ \implies t &= \frac{1}{1 - K} \\ \end{aligned}

### Case $K > 1$:

For this scenario, the times coincide for the first time after start when $B$ is exactly one cycle ahead of $A$. \begin{aligned} \theta_B &= \theta_A + 1 \\ \implies \omega_B t &= \omega_A t + 1 \\ \implies K t &= t + 1 \\ \implies t &= \frac{1}{K - 1} \\ \end{aligned}

For both cases, the clocks will continue to match again after every $t$ time. To find the $N^{th}$ instance we just need to calculate $t \times N$.

Now one cycle of $12$ hours, or half a day, was designated as unit time. So we must multiply $t \times N$ by $1/2$ to get the time in days. Taking the floor of this value will give required number of the day.

Note that it is necessary to manipulate the values as fractions because the inherent error in floating point calculations can result in a wrong answer.

# AUTHOR'S AND TESTER'S SOLUTION:

Author's solution can be found here
Tester's solution can be found here.

asked 16 Apr, 00:37

6★meooow ♦
7.0k717
accept rate: 48%

19.6k349497539

 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,182
×1,132
×53
×4

question asked: 16 Apr, 00:37

question was seen: 726 times

last updated: 20 Apr, 13:56