admin管理员组文章数量:1565291
Luck Competition
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 251 Accepted Submission(s): 155
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<N≤100) , denoting the number of participants. And next line contains N−1 numbers representing the numbers chosen by other participants.
Output For each test case, output an integer which you have chosen and the probability of winning (round to two digits after the decimal point), seperated by space.
Sample Input
3 4 1 2 3 4 1 1 2 4 20 30 40
Sample Output
1 0.50 0 1.00 18 1.00
Source "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<climits>
using namespace std;
int main()
{
int i,j,t,sum,n;
int num[110];
cin>>t;
while(t--)
{
cin>>n;
sum=0;
for(i=0;i<n-1;i++)
{
cin>>num[i];
sum+=num[i];
}
int x=2*sum/(3*n-2);
sum=1;
for(i=0;i<n-1;i++)
{
if(num[i]==x)
sum++;
}
cout<<x<<' ';
printf("%.2lf\n",(double)1/sum);
}
return 0;
}
本文标签: 女生competitionLuck
版权声明:本文标题:2016女生赛 1003 Luck Competition 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1726694000a1080990.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论