- شروع کننده موضوع
- #1
princess
کاربر نیمهفعال
- ارسالها
- 11
- امتیاز
- 7
- نام مرکز سمپاد
- فرزانگان تهران
- شهر
- تهران
- مدال المپیاد
- کامپیوتر ریاضی
- دانشگاه
- امیرکبیر
- رشته دانشگاه
- علوم کامپیوتر
faverage
محدودیت زمان پردازش: 1000 میلیثانیه
محدودیت حافظه: 32000 کیلوبایت
Funny Average
Think of how stupid the average person is, and realize half of them are stupider than that.
George Carlin
Take n integers.
Compute their average. Call it A1.
Throw away all the ones that are smaller than A1.
Compute the average of what remains. Call it A2.
Throw away all the integers that are larger than A2.
Compute the average of what remains. Call it A3.
Keep doing this forever, throwing away the small ones, then the large ones, then the small ones again, and so on. At some point, the average will stop changing. Your job is to figure out what that final "steady-state" average will be.
Input
The input starts with a line giving the number of test cases, N. Each test case will consist of two lines, the first one giving n (1 ≤ n ≤ 30000), and the second one giving n integers (each one between -30000 and 30000).
Output
For each test case, output one line containing "Case #" followed by the final average, rounded to 3 decimal places.
Sample
Standard Input
4
3
1 2 3
1
7
9
1 2 3 4 5 7 6 8 9
4
1 2 2 2
Standard Output
Case #1: 2.000
Case #2: 7.000
Case #3: 6.000
Case #4: 2.000
محدودیت زمان پردازش: 1000 میلیثانیه
محدودیت حافظه: 32000 کیلوبایت
Funny Average
Think of how stupid the average person is, and realize half of them are stupider than that.
George Carlin
Take n integers.
Compute their average. Call it A1.
Throw away all the ones that are smaller than A1.
Compute the average of what remains. Call it A2.
Throw away all the integers that are larger than A2.
Compute the average of what remains. Call it A3.
Keep doing this forever, throwing away the small ones, then the large ones, then the small ones again, and so on. At some point, the average will stop changing. Your job is to figure out what that final "steady-state" average will be.
Input
The input starts with a line giving the number of test cases, N. Each test case will consist of two lines, the first one giving n (1 ≤ n ≤ 30000), and the second one giving n integers (each one between -30000 and 30000).
Output
For each test case, output one line containing "Case #" followed by the final average, rounded to 3 decimal places.
Sample
Standard Input
4
3
1 2 3
1
7
9
1 2 3 4 5 7 6 8 9
4
1 2 2 2
Standard Output
Case #1: 2.000
Case #2: 7.000
Case #3: 6.000
Case #4: 2.000