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

×

Author: Ishpreet
Tester: Karan

SIMPLE

# PROBLEM:

There are total N stairs. A person climbs A stairs upwards in day and comes downstairs in night by B stairs. Find number of days person will take to reach the top of staircase.

# EXPLANATION:

Let us start by solving the problem day wise.
Day1: A               Night1: A-B
Day2: (A-B)+A      Night2: 2(A-B)
Day3: 2
(A-B)+A    Night3: 3(A-B)
....
DayX: (A - B) * (X - 1) + A,

Let us assume, on day X, he crossed N stairs.

So, (A - B) * (X - 1) + A >= N
AX - BX + B >= N
X (A - B) >= N - B
X >= (N - B) / (A - B)

All we need is the integer value of X which is >= (N - B) / (A - B).

# TESTER'S SOLUTION:

Ideone

This question is marked "community wiki".

asked 03 Apr '16, 13:28 4★ishpreet
9718
accept rate: 0% 19.8k350498541

 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,852
×1,191
×968
×14
×8
×2

question asked: 03 Apr '16, 13:28

question was seen: 1,582 times

last updated: 04 Apr '16, 15:12