Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Ankur has N magic sticks, each of some length. All magic sticks are of fixed length and cannot be broken. Now Ankur wants to
Ankur has N magic sticks, each of some length. All magic sticks are of fixed length and cannot be broken. Now Ankur wants to build a square using exactly 6 of those magic sticks. Now Ankur wonders in how many ways he can build a square using exactly 6 magic sticks. Help him to find the number of ways. Note: Two ways are considered different if they use at least one different stick. INPUT The first line contains an integer N, denoting the number of sticks. The second line contains N space-separated integers L, L2,..., Ln denoting the length of magic sticks. OUTPUT Output an integer representing the number of ways that 6 magic sticks can be used to make a Square CONSTRAINTS 6sN3000 1sLis10^7 EXPLANATION OF SAMPLE Sample input has 8 sticks of lengths 45151945 respectively. There are 3 ways of making a square using of combination of 6 of these sticks. Combination 1: Stick No. 1, 2, 3, 4, 5 and 7 Combination 2: Stick No. 1, 3, 4, 5, 7 and 8 Combination 3: Stick No. 1, 2, 3, 5, 7 and 8 Hence, the output for this sample case is 3. Sample Input 45151945 Sample Output 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
This question describes a combinatorial problem where we are given N magic sticks with various lengths The task is to determine the number of unique w...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started