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)
- 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
- Number of subsets with sum divisible by M | Set 2
- Program for nth Fuss–Catalan Number
- Count of subsets with sum equal to X
- Sum of subsets of all the subsets of an array | O(N)
- Count of pairs in an array such that the highest power of 2 that divides their product is 1
- Sum of Digits of the Good Strings
- Count non-adjacent subsets from numbers arranged in Circular fashion
- Modify the string such that every character gets replaced with the next character in the keyboard
- Generating all divisors of a number using its prime factorization
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.