HDU 5704 Luck Competition

Problem Description

Participants of the Luck Competition choose a non-negative integer no more than 100 in their mind. After choosing their number, let K be the average of all numbers, and M be the result of K×23. Then the lucky person is the one who choose the highest number no more than M. If there are several such people, the lucky person is chosen randomly.

If you are given a chance to know how many people are participating the competition and what their numbers are, calculate the highest number with the highest probability to win assuming that you’re joining the competition.

Input

There are several test cases and the first line contains the number of test cases T(T≤10).

Each test case begins with an integer N(1

#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n, i;
        long long sum, a[105], x;
        cin>>n;
        sum = 0;
        for(i = 0; i < n-1; i++)
        {
            cin>>a[i];
            sum += a[i];
        }
        x = (2 * sum) / (3 * n - 2);
        sum = 1;
        for(i = 0; i < n-1; i++)
        {
            if(a[i] == x)
                sum++;
        }
        cout<<x<<" ";
        printf("%.2f\n", (double)1/sum);

    }
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值