Given are the following values:

**N**which are the number of days left for the exams.**S**which are the number of subjects to be prepared for the exam.**C**which are the number of chapters to be prepared for each subject.**H**which are the number of hours to prepare a chapter.**L**which are the number of days of desired vacation. During this vacation, study cannot be done.**T**which are the number of hours that one can study in a day.

The task is to find if the desired vacation can be taken or not. If it can be obtained, then print **Yes**, else print **No**.

**Examples:**

Input:N = 1, S = 2, C = 3, H = 4, L = 5, T = 6

Output:No

required number of hours of study = S * C * H = 24

hours of study that can be done if the vacation is taken = (N – L) * T = -24

Since available time after vacation < total time required,

Hence vacation cannot be taken.

Input:N = 12, S = 5, C = 8, H = 3, L = 2, T = 20

Output:Yes

required number of hours of study = S * C * H = 120

hours of study that can be done if the vacation is taken = (N – L) * T = 200

Since available time after vacation > total time required,

Hence vacation can be taken.

**Approach:**

- Find the
**required number of hours of study**by multiplying**S**,**C**and**H**.

required number of hours of study = S * C * H

- Now find the
**hours of study that can be done if the vacation is taken**. These hours will be equivalent to the remaining days that we are left with multiplying by**T**hours(i.e., (N-L)*T).

hours of study that can be done if the vacation is taken = (N – L) * T

- Now check if the required hours are less than or equal to the hours of study that can be done if the vacation is taken. If true, then print
**Yes**, else print**No**. - Find the value of max(f(x)) - min(f(x)) for a given F(x)
- Find K such that |A - K| = |B - K|
- Find 2^(2^A) % B
- Find (1^n + 2^n + 3^n + 4^n) mod 5 | Set 2
- Find the value of f(n) / f(r) * f(n-r)
- Find N from the value of N!
- Find value of (1^n + 2^n + 3^n + 4^n ) mod 5
- Find value of (n^1 + n^2 + n^3 + n^4) mod 5 for given n
- Program to find sum of 1 + x/2! + x^2/3! +...+x^n/(n+1)!
- Given two numbers a and b find all x such that a % x = b
- Find two integers A and B such that A ^ N = A + N and B ^ N = B + N
- Program to find value of 1^k + 2^k + 3^k + ... + n^k
- Find x, y, z that satisfy 2/n = 1/x + 1/y + 1/z
- Find the ln(X) and log
_{10}X with the help of expansion - Find two numbers whose sum and GCD are given
- Find maximum value of x such that n! % (k^x) = 0
- Find (a^b)%m where 'a' is very large
- Find gcd(a^n, c) where a, n and c can vary from 1 to 10^9
- Find the sum of all multiples of 2 and 5 below N
- Find the value of N when F(N) = f(a)+f(b) where a+b is the minimum possible and a*b = N

Below is the implementation of the above approach:

## C++

`// C++ program to find ` `// if the Vacation can be taken or not ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find if the Vacation ` `// is possible or not ` `int` `isPossible(` `int` `N, ` `int` `S, ` `int` `C, ` `int` `H, ` ` ` `int` `L, ` `int` `T) ` `{ ` ` ` ` ` `// Find the required number of hours of study ` ` ` `int` `total_time_required = S * C * H; ` ` ` ` ` `// find the hours of study that can be done ` ` ` `// if the vacation is taken ` ` ` `int` `available_time_after_vacation = (N - L) * T; ` ` ` ` ` `// check if the required hours are less than ` ` ` `// or equal to the hours of study ` ` ` `// that can be done if the vacation is taken ` ` ` `if` `(available_time_after_vacation ` ` ` `>= total_time_required) ` ` ` `return` `1; ` ` ` `return` `0; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `N = 12, S = 5, C = 8, ` ` ` `H = 3, L = 2, T = 20; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T)) ` ` ` `cout << ` `"Yes"` `<< endl; ` ` ` `else` ` ` `cout << ` `"No"` `<< endl; ` ` ` ` ` `N = 1, S = 2, C = 3, ` ` ` `H = 4, L = 5, T = 6; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T)) ` ` ` `cout << ` `"Yes"` `<< endl; ` ` ` `else` ` ` `cout << ` `"No"` `<< endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find ` `// if the Vacation can be taken or not ` `class` `GFG ` `{ ` ` ` `// Function to find if the Vacation ` `// is possible or not ` `static` `int` `isPossible(` `int` `N, ` `int` `S, ` `int` `C, ` `int` `H, ` ` ` `int` `L, ` `int` `T) ` `{ ` ` ` ` ` `// Find the required number of hours of study ` ` ` `int` `total_time_required = S * C * H; ` ` ` ` ` `// find the hours of study that can be done ` ` ` `// if the vacation is taken ` ` ` `int` `available_time_after_vacation = (N - L) * T; ` ` ` ` ` `// check if the required hours are less than ` ` ` `// or equal to the hours of study ` ` ` `// that can be done if the vacation is taken ` ` ` `if` `(available_time_after_vacation ` ` ` `>= total_time_required) ` ` ` `return` `1` `; ` ` ` `return` `0` `; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `N = ` `12` `, S = ` `5` `, C = ` `8` `, ` ` ` `H = ` `3` `, L = ` `2` `, T = ` `20` `; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T) == ` `1` `) ` ` ` `System.out.print(` `"Yes"` `+ ` `"\n"` `); ` ` ` `else` ` ` `System.out.print(` `"No"` `+ ` `"\n"` `); ` ` ` ` ` `N = ` `1` `; S = ` `2` `; C = ` `3` `; ` ` ` `H = ` `4` `; L = ` `5` `; T = ` `6` `; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T)==` `1` `) ` ` ` `System.out.print(` `"Yes"` `+ ` `"\n"` `); ` ` ` `else` ` ` `System.out.print(` `"No"` `+ ` `"\n"` `); ` `} ` `} ` ` ` `// This code is contributed by 29AjayKumar ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find ` `# if the Vacation can be taken or not ` ` ` `# Function to find if the Vacation ` `# is possible or not ` `def` `isPossible(N, S, C, H, L, T): ` ` ` ` ` `# Find the required number of hours of study ` ` ` `total_time_required ` `=` `S ` `*` `C ` `*` `H ` ` ` ` ` `# find the hours of study that can be done ` ` ` `# if the vacation is taken ` ` ` `available_time_after_vacation ` `=` `(N ` `-` `L) ` `*` `T ` ` ` ` ` `# check if the required hours are less than ` ` ` `# or equal to the hours of study ` ` ` `# that can be done if the vacation is taken ` ` ` `if` `(available_time_after_vacation >` `=` `total_time_required): ` ` ` `return` `1` ` ` `return` `0` ` ` `# Driver Code ` `N ` `=` `12` `S ` `=` `5` `C ` `=` `8` `H ` `=` `3` `L ` `=` `2` `T ` `=` `20` ` ` `if` `(isPossible(N, S, C, H, L, T)): ` ` ` `print` `(` `"Yes"` `) ` `else` `: ` ` ` `print` `(` `"No"` `) ` ` ` `N ` `=` `1` `S ` `=` `2` `C ` `=` `3` `H ` `=` `4` `L ` `=` `5` `T ` `=` `6` ` ` `if` `(isPossible(N, S, C, H, L, T)): ` ` ` `print` `(` `"Yes"` `) ` `else` `: ` ` ` `print` `(` `"No"` `) ` ` ` `# This code is contributed by SHUBHAMSINGH10 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find ` `// if the Vacation can be taken or not ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find if the Vacation ` `// is possible or not ` `static` `int` `isPossible(` `int` `N, ` `int` `S, ` `int` `C, ` `int` `H, ` ` ` `int` `L, ` `int` `T) ` `{ ` ` ` ` ` `// Find the required number of hours of study ` ` ` `int` `total_time_required = S * C * H; ` ` ` ` ` `// find the hours of study that can be done ` ` ` `// if the vacation is taken ` ` ` `int` `available_time_after_vacation = (N - L) * T; ` ` ` ` ` `// check if the required hours are less than ` ` ` `// or equal to the hours of study ` ` ` `// that can be done if the vacation is taken ` ` ` `if` `(available_time_after_vacation ` ` ` `>= total_time_required) ` ` ` `return` `1; ` ` ` `return` `0; ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main(String[] args) ` `{ ` ` ` `int` `N = 12, S = 5, C = 8, ` ` ` `H = 3, L = 2, T = 20; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T) == 1) ` ` ` `Console.Write(` `"Yes"` `+ ` `"\n"` `); ` ` ` `else` ` ` `Console.Write(` `"No"` `+ ` `"\n"` `); ` ` ` ` ` `N = 1; S = 2; C = 3; ` ` ` `H = 4; L = 5; T = 6; ` ` ` ` ` `if` `(isPossible(N, S, C, H, L, T)==1) ` ` ` `Console.Write(` `"Yes"` `+ ` `"\n"` `); ` ` ` `else` ` ` `Console.Write(` `"No"` `+ ` `"\n"` `); ` `} ` `} ` ` ` `// This code is contributed by 29AjayKumar ` |

*chevron_right*

*filter_none*

**Output:**

Yes No

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

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.