{"id":"ef8519e3-243f-4d73-b967-8cc5b35a5a0b","name":"Linear Equation Of N Variables","description":"1. You are given an array(arr), which represents the coefficients of a linear equation of n variables.\r\n2. You are also given a number, which represents R.H.S of the equation.\r\n For the equation 3x + 4y + 5z = 15\r\n Array will be -> [3,4,5] and R.H.S will be -> 15 \r\n3. You have to find the number of non-negative integer solutions of the given equation.","inputFormat":"A number N\r\narr1\r\narr2... N numbers\r\nA number X","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= N &lt;= 10^3\r\n1 &lt;= arr[i] &lt;= 10^3\r\n1 &lt;= X &lt;= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static long solution(int[] arr, int x) {\r\n //write your code here\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for (int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n int x = scn.nextInt();\r\n System.out.println(solution(arr, x));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n1 2 3\r\n4","sampleOutput":"4","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"472e4593-cc90-46c2-a929-2b7d9515a134","name":"Linear Equation Of N Variables","slug":"linear-equation-of-n-variables","type":1}],"next":{"id":"1ee90a75-1600-40e7-b230-ca2f74f93b82","name":"Minimum Deletions To Make Palindromic Sequence","type":1,"slug":"minimum-deletions-to-make-palindromic-sequence"},"prev":{"id":"0d21e3b0-95a8-444c-99f8-abb8f9a05469","name":"Find Water in Glass MCQ","type":0,"slug":"find-water-in-glass-mcq"}}}

Linear Equation Of N Variables

1. You are given an array(arr), which represents the coefficients of a linear equation of n variables. 2. You are also given a number, which represents R.H.S of the equation. For the equation 3x + 4y + 5z = 15 Array will be -> [3,4,5] and R.H.S will be -> 15 3. You have to find the number of non-negative integer solutions of the given equation.

{"id":"ef8519e3-243f-4d73-b967-8cc5b35a5a0b","name":"Linear Equation Of N Variables","description":"1. You are given an array(arr), which represents the coefficients of a linear equation of n variables.\r\n2. You are also given a number, which represents R.H.S of the equation.\r\n For the equation 3x + 4y + 5z = 15\r\n Array will be -> [3,4,5] and R.H.S will be -> 15 \r\n3. You have to find the number of non-negative integer solutions of the given equation.","inputFormat":"A number N\r\narr1\r\narr2... N numbers\r\nA number X","outputFormat":"Check the sample output and question video.","constraints":"1 &lt;= N &lt;= 10^3\r\n1 &lt;= arr[i] &lt;= 10^3\r\n1 &lt;= X &lt;= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static long solution(int[] arr, int x) {\r\n //write your code here\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n int[] arr = new int[n];\r\n for (int i = 0 ; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n int x = scn.nextInt();\r\n System.out.println(solution(arr, x));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"3\r\n1 2 3\r\n4","sampleOutput":"4","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"472e4593-cc90-46c2-a929-2b7d9515a134","name":"Linear Equation Of N Variables","slug":"linear-equation-of-n-variables","type":1}],"next":{"id":"1ee90a75-1600-40e7-b230-ca2f74f93b82","name":"Minimum Deletions To Make Palindromic Sequence","type":1,"slug":"minimum-deletions-to-make-palindromic-sequence"},"prev":{"id":"0d21e3b0-95a8-444c-99f8-abb8f9a05469","name":"Find Water in Glass MCQ","type":0,"slug":"find-water-in-glass-mcq"}}}
plane

Editor


Loading...

Linear Equation Of N Variables

medium

1. You are given an array(arr), which represents the coefficients of a linear equation of n variables. 2. You are also given a number, which represents R.H.S of the equation. For the equation 3x + 4y + 5z = 15 Array will be -> [3,4,5] and R.H.S will be -> 15 3. You have to find the number of non-negative integer solutions of the given equation.

Constraints

1 <= N <= 10^3 1 <= arr[i] <= 10^3 1 <= X <= 10^4

Format

Input

A number N arr1 arr2... N numbers A number X

Output

Check the sample output and question video.

Example

Sample Input

3 1 2 3 4

Sample Output

4

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode