Given the number of questions as , and marks for the correct answer as and marks for the incorrect answer. One can either attempt to solve the question in an examination and get either marks if the answer is right, or marks if the answer is wrong, or leave the question unattended and get marks. The task is to find the count of all the different possible marks that one can score in the examination.
Input: n = 2, p = 1, q = -1
The different possible marks are: -2, -1, 0, 1, 2
Input: n = 4, p = 2, q = -1
Approach: Iterate through all the possible number of correctly solved and unsolved problems. Store the scores in a set containing distinct elements keeping in mind that there is a positive number of incorrectly solved problems.
Below is the implementation of the above approach:
Please Login to comment...