2015 Mock CCC by Alex and Timothy

Problem J2: Lowest Exam Mark

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" (without quotes).

Sample Input 1

85
90
30

Sample Output 1

100

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

36
50
20

Sample Output 2

DROP THE COURSE

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.

All Submissions
Best Solutions


Point Value: 5
Time Limit: 1.00s
Memory Limit: 64M
Added: Feb 18, 2015
Author: Alex

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

how to do test case 4? if the test mark that you want is lower than the what you already have?

peter, youre solution is hacking, why, would y ou do that, you dont learn anything, try not to do this next time

and how to to test case number four, either look at my solution or set i as 0,

Hardcoding inputs is against the rules. Please don't do this. Your submissions may be deleted without warning.

yes, you're right jargon senpai

but that theory does not work on the test cases, or maybe im not smart

oh, i think i might get it

please help me explain the sample one, since if she got like 100 percent on her test, it would be 100*0.3 which does not equal to 89.5-85, so yeah

Let's say I have 2 tests in my class and I got 90% on the first one.

Now, if the second test is worth 50%, and I get 70% on it, do I have 160% overall?

Exams are in 3 weeks... rip life.