Question
Magic Sticksfixed lengthNote:INPUTNSecond line containNs L12NOUTPUT Ankur has N magic sticks, each of some length. All magic sticks are of and cannot be broken. Now
Magic Sticksfixed length Note: INPUT NSecond line contain Ns L12NOUTPUT
Ankur has N magic sticks, each of some length. All magic sticks are of 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.
Two ways are considered different if they use at least one different stick.
The first line contains an integer, denoting the number of sticks.
space seperated integer, L, ...., L denoting length of magic sticks.
Output an integer representing the number of ways that 6 magic sticks can be used to make as square.
CONSTRAINTS
6≤N≤3000
1≤Li≤10^7
EXPLANATION OF SAMPLE
Sample input has 8 sticks of lengths 4,5,1,5,1,9,4,5, 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
8
4 5 1 5 1 9 4 5
Sample Output
3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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