Valentine's Day '18 J2 - Stop the Scammer

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Carol has been scammed!

You, as Carol's dear friend seek justice against this scammer. To do so, you devise a master plan - you will write Medium articles to get attention from the press. However, this is no simple process. Each Medium article you write will receive fewer claps than the previous article, and you must achieve a total of at least N claps to take down the scammer. Your penultimate article will result in a cease and desist, after which you must write an article about receiving the cease and desist - this article will receive the sum of all claps from all previous articles.

Your first article receives X claps, and every subsequent article receives Y claps fewer than the previous article. An article cannot receive a negative number of claps, in that event it would receive zero claps. What is the minimum number of Medium articles you must write before the cease and desist to achieve at least N claps?


1 \le N \le 10^6

1 \le X, Y \le 10^3

Input Specification

The first line will contain N, the number of claps required.

The following line will contain X and Y.

Output Specification

If it's not possible to obtain justice, output RIP.

Otherwise, output the number of articles it will take (excluding the cease and desist article) to obtain justice.

Sample Input

400 200

Sample Output


Sample Input

300 20

Sample Output



  • -2
    hoymistere  commented on Nov. 27, 2018, 4:51 p.m.

    I knew that, didn't help

    • 0
      kipply  commented on Nov. 28, 2018, 8:47 p.m.

      I need context to understand this.

  • 8
    felixzhang25  commented on April 1, 2018, 10:24 a.m. edited

    If it's not possible to obtain justice, output "RIP".