Product Square
Practice
3.9 (394 votes)
Mathematics
Easy Medium
Hash function
Greedy algorithm
Problem
33% Success 5266 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Arjit loved his family.He enjoyed spending time with them.And it was no different on the New Year.

He took his family on a picnic.Made some delicious chicken so that everyone could have a quality time.After few hours of leisure he told Ram and Mohan , his sons to go out and play badminton.After a while he saw that a severe fight took place between his sons. Arjit got really angry on seeing this and he decided to teach his sons a lesson.

He give them a puzzle to solve and told them that until and unless they solve it they are not allowed to play anything.Ram and Mohan got pretty worried on hearing this .But they decided they will give their heart out to solve this puzzle.

Arjit gave them N integers initially .Since Ram was older than Mohan he asked Ram to pick one integer randomly.After that the integer that Ram picked was removed and only N-1 integer remained.He then asked Mohan to pick 1 integer from the remaining N-1 integers.When both of them had chosen their elements he told them to multiply both the values.Both Ram and Mohan were really happy till now coz they thought that it was a piece of cake but then Arjit smiled and they realized something bad is coming. Arjit asked them to tell him what is the probability that the multiplied value is a perfect square.Both of them got awe struck on hearing this.

They turn to you to for help so that they can enjoy their picnic.

Input:

The first line contains N indicating the size of array.This is followed up by N line separated integers given by Arjit to his sons.

Output:

The probability that the product of chosen number would be a perfect square.Print exactly 6 decimal places.

Constraints:

1 <= N <= 10^5

1<= Array Value < = 5000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
3 votes
Tags:
Ad-HocData StructuresOpenApprovedEasyMathamatics
Points:30
2 votes
Tags:
Easy-Medium
Points:50
72 votes
Tags:
ReadyBasic ProgrammingMedium-HardGreatest common divisorMathematics