F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Lottery

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 230    Accepted Submission(s): 5
Special Judge


Problem Description
Your living city is holding a big lottery game now! There are M people in this city who want to play this lottery. Everyone of them must pay C dollars to get a lottery ticket. Taking this ticket, he can get a chance to win a prize by randomly selecting one from N indistinguishable boxes and getting the prize if there is a ball in the selected box. The ball in the selected box is also taken by this winner, so if a box with a ball happens to be selected by a player, it will never contain balls from then on, but it will be closed and can be selected by the future players. Every box contains exactly one ball at the beginning, and two or more players cannot select the boxes and the same time.

Of course, the latter you join this game, the less the chance you win a prize will be. So the lottery holder make such a rule: If you are the n-th player who wins a prize, you will get A*(n-1)+B dollars. That is to say, the first winner will get B dollars, the second winner will get A+B dollars, the income of the third winner is 2*A+B, and so on.

Being curious about the expected profit, the lottery holder is too lazy to calculate it himself. So he finds you and give you a lot of money to do this work. If you can solve it quickly, you will be a millionaire!
 

Input
The first line of input is a integer T, the number of test cases. Each case contains exactly 5 integers M, N, C, A, B in this order, where 1 <= M, N <= 10^6 and 0 <= C, A, B <= 100.
 

Output
For each test case, print a line contains a single real number which is the expected profit got. You can output the result with any precision you like, but the relative error should less than or equal to 1e-5.
 

Sample Input
3 1 2 10 5 7 2 2 10 5 7 7 5 0 0 1
 

Sample Output
3 7 -3.95142
 

Author
wywcgs
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 18:22:54, Gzip enabled