# Problems not solved at the end of Nth day

Given 3 integers K, P and N. Where, K is the number of problems given to the person every day and P is the maximum number of problems he can solve in a day. Find the total number of problems not solved after the N-th day.

**Examples**:

Input: K = 2, P = 1, N = 3Output: 3 On each day 1 problem is left so 3*1 = 3 problems left after Nth day.Input: K = 4, P = 1, N = 10Output: 30

If P is greater than or equal to K then all problems will be solved on that day or (K-P) problems will be solved on each day so the answer will be 0 if K<=P else the answer will be (K-P)*N.

Below is the implementation of the above approach:

## C++

`// C++ program to find problems not ` `// solved at the end of Nth day ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find problems not ` `// solved at the end of Nth day ` `int` `problemsLeft(` `int` `K, ` `int` `P, ` `int` `N) ` `{ ` ` ` `if` `(K <= P) ` ` ` `return` `0; ` ` ` `else` ` ` `return` `(K - P) * N; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `K, P, N; ` ` ` ` ` `K = 4; ` ` ` `P = 1; ` ` ` `N = 10; ` ` ` ` ` `cout << problemsLeft(K, P, N); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find problems not ` `// solved at the end of Nth day ` ` ` `class` `Gfg { ` ` ` ` ` `// Function to find problems not ` ` ` `// solved at the end of Nth day ` ` ` `public` `static` `int` `problemsLeft(` `int` `K, ` `int` `P, ` `int` `N) ` ` ` `{ ` ` ` `if` `(K <= P) ` ` ` `return` `0` `; ` ` ` `else` ` ` `return` `((K - P) * N); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `int` `K, P, N; ` ` ` `K = ` `4` `; ` ` ` `P = ` `1` `; ` ` ` `N = ` `10` `; ` ` ` ` ` `System.out.println(problemsLeft(K, P, N)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python program to find problems not ` `# solved at the end of Nth day ` ` ` `def` `problemsLeft(K, P, N): ` ` ` `if` `(K<` `=` `P): ` ` ` `return` `0` ` ` `else` `: ` ` ` `return` `((K` `-` `P)` `*` `N) ` ` ` `# Driver Code ` `K, P, N ` `=` `4` `, ` `1` `, ` `10` ` ` `print` `(problemsLeft(K, P, N)) ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find problems not ` `// solved at the end of Nth day ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find problems not ` `// solved at the end of Nth day ` `public` `static` `int` `problemsLeft(` `int` `K, ` ` ` `int` `P, ` `int` `N) ` `{ ` ` ` `if` `(K <= P) ` ` ` `return` `0; ` ` ` `else` ` ` `return` `((K - P) * N); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `K, P, N; ` ` ` `K = 4; ` ` ` `P = 1; ` ` ` `N = 10; ` ` ` ` ` `Console.WriteLine(problemsLeft(K, P, N)); ` `} ` `} ` ` ` `// This code is contributed by vt_m ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find problems not ` `// solved at the end of Nth day ` ` ` `// Function to find problems not ` `// solved at the end of Nth day ` `function` `problemsLeft(` `$K` `, ` `$P` `, ` `$N` `) ` `{ ` ` ` `if` `(` `$K` `<= ` `$P` `) ` ` ` `return` `0; ` ` ` `else` ` ` `return` `(` `$K` `- ` `$P` `) * ` `$N` `; ` `} ` ` ` `// Driver Code ` `$K` `= 4; ` `$P` `= 1; ` `$N` `= 10; ` ` ` `echo` `problemsLeft(` `$K` `, ` `$P` `, ` `$N` `); ` ` ` `// This code is contributed by anuj_67 ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

30

## Recommended Posts:

- CBSE 12th class Paper Solved - 2015-16 session
- Some Tricks to solve problems on Impartial games
- Applying Multinomial Naive Bayes to NLP Problems
- Number of ways N can be divided into four parts to construct a rectangle
- Find the count of natural Hexadecimal numbers of size N
- Largest Even and Odd N-digit numbers in Octal Number System
- Number of K length subsequences with minimum sum
- Hyperlink Induced Topic Search (HITS) Algorithm using Networxx Module | Python
- Check whether the given integers a, b, c and d are in proportion
- Count of matchsticks required to represent the given number
- Count number of ways to arrange first N numbers
- Probability that a random pair chosen from an array (a[i], a[j]) has the maximum sum
- Number of triangles that can be formed
- Find the deleted value from the array when average of original elements is given

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.