Find the value of a1, a2, a3, ….an such that the following two conditions are satisfied.
Print the value of a1, a2, …, an and “No solution” otherwise.
Note: There maybe a several solutions, print any of them .
Input: n = 5, x = 15, y = 15 Output: 11 1 1 1 1 Input: n = 4, x = 324, y = 77 Output: 74 1 1 1
Approach: Below is the step by step algorithm to solve this problem:
- Initialize the number of elements and the value of x and y.
- There is no solution of a1…a2 if y is less than n or if x is very larger than n.
- Print first solution as y – n + 1 and 1 as the solution of rest of the elements.
Below is the implementation of above approach:
11 1 1 1 1
- Number of solutions to Modular Equations
- Find the repeating and the missing number using two equations
- Find the number of solutions to the given equation
- Find number of solutions of a linear equation of n variables
- Program to find number of solutions in Quadratic Equation
- Find the values of X and Y in the Given Equations
- Find n-variables from n sum equations with one missing
- Find n positive integers that satisfy the given equations
- Program to find root of an equations using secant method
- Number of solutions for x < y, where a <= x <= b and c <= y <= d and x, y are integers
- Number of solutions of n = x + n ⊕ x
- Number of solutions for the equation x + y + z <= n
- Number of integral solutions of the equation x1 + x2 +.... + xN = k
- Count number of solutions of x^2 = 1 (mod p) in given range
- Number of non-negative integral solutions of a + b + c = n
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.