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:
- Pairs of Positive Negative values in an array
- Find subarray with given sum | Set 2 (Handles Negative Numbers)
- Combination and Permutation Practice Questions | Set 1
- Top 20 Hashing Technique based Interview Questions
- Only integer with positive value in positive negative value in array
- Remove all occurrences of any element for maximum array sum
- Product of all Subsequences of size K except the minimum and maximum Elements
- Count arrays of length K whose product of elements is same as that of given array
- Count different numbers possible using all the digits their frequency times
- Number of Positions to partition the string such that atleast m characters with same frequency are present in each substring
- Sum of elements in 1st array such that number of elements less than or equal to them in 2nd array is maximum
- Number of subsequences with zero sum
- 3-digit Osiris number
- Dudeney Numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.