"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5704
来源:互联网 发布:ubuntu登陆后桌面假死 编辑:程序博客网 时间:2024/05/14 17:19
Luck Competition
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 11 Accepted Submission(s): 6
Problem Description
Participants of the Luck Competition choose a non-negative integer no more than 100 in their mind. After choosing their number, letK 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.
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 casesT(T≤10) .
Each test case begins with an integerN(1<N≤100) , denoting the number of participants. And next line contains N−1 numbers representing the numbers chosen by other participants.
Each test case begins with an integer
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
341 2 341 1 2420 30 40
Sample Output
1 0.500 1.0018 1.00
Source
"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场
Recommend
liuyiding | We have carefully selected several similar problems for you: 5711 5710 5709 5708 5700
水题 瞎JB模拟
#include <iostream>#include <cmath>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;//void printf(int begin,int end,int mid)//{// int i;// if(begin>end)// return;// for(i=begin; i<=end; i++)// if(b[i]==a[mid])// break;// printf(begin,i-1,mid+1); //中序,先左,后跟,再右。此时i为跟节点,左子树必定在begin到i-1里面。// printf(i+1,end,mid-begin+i+1);//中序,先左,后跟,再右。此时i为跟节点,右子树必定在i+1到end里面。// cout<<a[mid];// if(mid==1)// cout<<endl;// else// cout<<" ";//}//struct node//{// int id;// char s[1000];//};//bool cmp(node a,node b)//{// return a.id>b.id;//}//char s[1005][1005];//int dir[4][2]= {1,0,-1,0,0,1,0,-1};//char g[5]= {"girl"};//char c[5]= {"cat"};//int n,m;//int dfs1(int x,int y,int cnt)//{// int i;// if(x<0 ||y<0 ||x>=n ||y>=m)// return 0;// if(s[x][y]!=g[cnt])// return 0;// if(cnt==3)// return 1;// int res=0;// for(i=0; i<4; i++)// {// int dx=x+dir[i][0];// int dy=y+dir[i][1];// res+=dfs1(dx,dy,cnt+1);// }// return res;//}//int dfs2(int x,int y,int cnt)//{// int i;// if(x<0 ||y<0 ||x>=n ||y>=m)// return 0;// if(s[x][y]!=c[cnt])// return 0;// if(cnt==2)// return 1;// int res=0;// for(i=0; i<4; i++)// {// int dx=x+dir[i][0];// int dy=y+dir[i][1];// res+=dfs2(dx,dy,cnt+1);// }// return res;//}int main(){ int t; scanf("%d",&t); while(t--) { int i; int n; cin>>n; int ans[105]; memset(ans,0,sizeof(ans)); int sum=0; for(i=0; i<n-1; i++) { int x; cin>>x; sum+=x; ans[x]++; } for(i=100; i>=0; i--) ans[i]+=ans[i+1]; int id; int res=343434; int eee; for(i=0; i<=100; i++) { int op=i+sum; op=op*2/(3*n); if(i<=op &&(i+1>op || ans[i+1]==0)) //前面没人,i为最接近op的。 { if(ans[i]-ans[i+1]<=res) { id=i; res=ans[i]-ans[i+1]; eee=ans[i]; } } } // cout<<eee<<endl; // cout<<res<<endl; // cout<<1.0/(eee+1)<<endl; printf("%d %.2lf\n",id,1.0/(res+1)); }}
0 0
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5704
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5702
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5703
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5705
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5706
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5707
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)解题思路
- HDU "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 1001-1006
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场 Combine String
- hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)
- HDU Fraction 2016中国大学生程序设计竞赛(长春)-重现赛
- HDU Triangle 2016中国大学生程序设计竞赛(长春)-重现赛
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场-1001-Solving Order
- HDU Harmonic Value Description 2016中国大学生程序设计竞赛(长春)-重现赛
- HDU Sequence I 2016中国大学生程序设计竞赛(长春)-重现赛
- linux互斥锁的基本知识
- C++第6次实验(数组操作)
- XenServer架构之XAPI的调用流程
- Geekband C++面向对象高级编程(上) 第三周笔记 暗影行者
- 理解Java中HashMap的工作原理
- "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现) HDU 5704
- IEEE 802.15.4协议完整中文版 - 目录
- Ubuntu默认root用户密码
- Codeforces Round #200 (Div. 1) D - Water Tree 很经典而且很有趣的树 上dfs问题
- spring、springmvc、mybatis整合(SSM)
- spring mvc中的登录拦截器java类中,重写的三个方法是什么意思()
- html5本地存储localStorage 存储json对象存储格式问题
- 《java入门第一季》之Socket编程通信和TCP协议通信图解
- Ubuntun