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
- Rearrange characters in a string such that no two adjacent are same using hashing
- Design a stack which can give maximum frequency element
- Check whether array has all identical elements using Arrays.asList() and HashSet in Java
- Iterative approach to print all permutations of an Array
- Iterative approach to print all combinations of an Array
- Find uncommon characters of the two strings | Set 2
- Number of ways to arrange a word such that no vowels occur together
- Count duplicates in a given linked list
- Find if nCr is divisible by the given prime
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.