Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

PLZLYKME - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Kaushik Iska
Tester:Gerald Agapov
Editorialist:Jingbo Shang

DIFFICULTY:

Simple

PREREQUISITES:

Programming Language

PROBLEM:

Define F[1] = S, F[i > 0] = F[i - 1] * (C + 1). Determine whether F[D] >= L.

EXPLANATION:

First of all ,we need to observe that F[] is monotone increasing, because of (C + 1) > 1.

Second, F[] is increasing exponentially, while L is smaller than 10^9. That means, only O(log L) days are needed for F[D] to exceed L.

Third, when F[] exceed L, it is possible about 10^18 (exceeding int in C++ and Java). So please choose the appropriate type to store.

In summary, what we need to do is calculate F[0..D] one by one, until all D + 1 ones are got or some one is greater than L. The time complexity is in O(min{D, log L}).

AUTHOR'S AND TESTER'S SOLUTIONS:

Solutions will be uploaded soon. Author's solution can be found here.
Tester's solution can be found here.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>