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 Output: 5 The different possible marks are: -2, -1, 0, 1, 2 Input: n = 4, p = 2, q = -1 Output: 12
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:
- Find subarray with given sum | Set 2 (Handles Negative Numbers)
- Pairs of Positive Negative values in an array
- Only integer with positive value in positive negative value in array
- Combination and Permutation Practice Questions | Set 1
- Top 20 Hashing Technique based Interview Questions
- Product of elements in an array having prime frequency
- Print characters having even frequencies in order of occurrence
- Area of the largest square that can be formed from the given length sticks using Hashing
- Count of distinct graphs that can be formed with N vertices
- Number of Subsequences with Even and Odd Sum | Set 2
- Print all the permutations of a string without repetition using Collections in Java
- Ways to choose balls such that at least one ball is chosen
- Print the season name of the year based on the month number
- Count permutation such that sequence is non decreasing
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.