Utkarsh and Faulty Rain Gauge
Practice
3.4 (54 votes)
Exception handling
Mathematics
Probability and statistics
Easy
Problem
49% Success 975 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Utkarsh is going to Cherrapunji to visit his brother Saharsh. Cherrapunji faces one of largest rainfall in the country. So, Saharsh and Utkarsh decided to measure this rainfall by T Rain Gauges. They were going to measure it by taking the product of the readings of all the gauges. But, they found out that the gauges were not working properly and were producing random values. The brothers want to know what will be the expected result of the experiment.

The ith Rain Gauge has a least count of 1/Ri units. It has Ni divisions on its surface. Formally, it can give any reading from the set {0, 1/Ri , 2/Ri , ... ,Ni/Ri}. It gives a reading x with a probability proportional to x2.


Input Format:
The first line contains the integer T. T lines follow each containing 2 integers - Ni and Ri.


Output format:
Print the answer to the problem as real number exactly 4 decimal places. It is guaranteed that the answer is always less than 109.


Constraints:
1 ≤ T ≤ 103
1 ≤ Ni ≤ 103
1 ≤ Ri ≤ 103

NOTE:

  • A function p(x) is said to be proportional to x2 means p(x) = ax2 for some non negative a.

  • All the rain gauges produce values independently from each other.
  • 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
    Tags:
    Easy
    Points:20
    6 votes
    Tags:
    MathematicsOpenApprovedEasy
    Points:20
    7 votes
    Tags:
    MathematicsProbability and StatisticsEasy