Lowest Exam Mark

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
2015 Mock CCC by Alex and Timothy

It's midterm examination season! The most frequently asked question in high schools across Canada is, of course, "what is the lowest mark I have to get on the exam to end up with X\% overall?"

Berta currently has exactly P percent in her class and prepares to write an exam that will be worth W percent of her overall mark afterwards. Her goal is to reach a mark of Q percent after the exam. Note that after inputting Berta's exam mark, her teacher will round her overall mark (half-up) to the nearest percent to be displayed. What is the minimum mark that she must obtain on the exam to have an overall mark that rounds to Q percent or over?

Input Format

Line 1 will contain P, the percentage mark she currently has.
Line 2 will contain Q, the percentage mark she would like to have.
Line 3 will contain W, the weight of the exam.
The input will only contain integers between 0 and 100, inclusive.

Output Format

Output a single integer, the minimum integer percentage that must be obtained on the exam to reach a final mark that rounds to Q percent or greater. If this is not possible, Berta knows that the mark is probably not going to look good on her report card. In this case you should output only the line DROP THE COURSE.

Sample Input 1


Sample Output 1


Explanation for Sample 1

Berta has a 85% and prepares to take her midterm exam that will be worth 30% of her final mark. Assuming she gets perfect on her exam, her overall mark will be 89.5% afterwards, which just barely rounds up to a 90% for her final mark.

Sample Input 2


Sample Output 2


Explanation for Sample 2

Here, Berta has a 36% and just wants to pass the course with a 50%. However, even with a perfect exam, she can only end up with 48.8% overall.


  • -2
    jaydenchu2003  commented on Dec. 6, 2019, 6:27 p.m.

    what happens if you have a 63 and want a 90?

    since you need about 157%, do I write "DROP THE COURSE"?

  • 1
    Laurak121  commented on Nov. 18, 2018, 12:34 p.m.

    Is it possible that the inputs are decimals?

    • 2
      russellbrowman  commented on April 25, 2019, 12:18 a.m.

      no thei r integrslaurak121 😎😎😎😎

  • -3
    elbowjoint  commented on April 4, 2018, 5:14 p.m.

    i have got it, brothers

  • -6
    elbowjoint  commented on April 4, 2018, 12:41 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.

  • 3
    Pleedoh  commented on May 24, 2017, 9:57 p.m.

    What is test case #4? What am I doing wrong?

    • 0
      MattP77  commented on Jan. 5, 2018, 8:47 p.m.

      Did you figure it out? #4 says WA for me too.

      • 3
        TheZombieCloud  commented on Jan. 5, 2018, 9:18 p.m. edited

        If the exam mark required is a negative, that means you have to score worse than 0% to achieve the desired score. Since this question is asking for the minimum mark to achieve at least the desired score, you should just output 0%.

        • 1
          Laurak121  commented on Nov. 18, 2018, 12:28 p.m.

          Thanks for that

  • 0
    Quality_of_Perfection  commented on July 15, 2016, 6:57 p.m.

    My submission for the Lowest Exam Mark won't give me a score. Now when I try to submit any problem, it says that I have made too many submissions. Can someone please help me ?

  • 5
    LOLWHATOMGBBQ  commented on Feb. 15, 2015, 12:25 p.m.

    What happens when W = 0?

    • 1
      Laurak121  commented on Nov. 20, 2018, 7:53 p.m.

      I don't get it.

    • 4
      Kirito  commented on April 30, 2016, 6:27 p.m.

      Then you have a very nice teacher.

    • 4
      FatalEagle  commented on Feb. 15, 2015, 1:14 p.m.

      No comment.

      • 7
        bobhob314  commented on Feb. 15, 2015, 3:44 p.m.

        What but there IS a comment?? Two actually... I'm confused can someone help me