Make Anonymous be the lucky guy
来源:互联网 发布:广州美工培训学校 编辑:程序博客网 时间:2024/05/16 01:45
Description
近来,校队队员都感到无比无聊,除了每天刷题之外,没有事情可以提高幸福指数,于是队内的PaulZhou决定带领大家做游戏,校队一共有n名队员,每个人选择一个0至100的数字,所选数字小于等于所有数字的平均值的3/4并最接近者获胜,若此时有多个人满足获胜条件则随机抽取一位定为获胜者。
由于最近Anonymous沉迷于数据结构作业无法自拔,导致她运气极差,已经连输多场,PaulZhou为了照顾她的情绪决定偷偷给她看所有人选择的数字。
Anonymous喜欢大数字并且不想让人知道她作弊,由于她最近写数据结构作业傻掉了,所以你需要帮助Anonymous选择出一个可能获胜的最大数字,并计算出获胜的概率
Input
第一行输入一个整数T(T<=10),表示测试实例的个数;
接下来对每个实例,先输入一个整数n(n<=100),表示校队的人数,接下来输入n-1个数,表示除Anonymous以外,其他人选择的数字。
Output
对于每组实例,输出一个整数――表示Anonymous选择的数字,以及Anonymous获胜的概率,保留两位小数。
Sample Input
2
5
1 2 3 4
4
1 1 2
Sample Output
1 0.50
0 1.00
Hint
题意
题解:
AC代码
#include <cstdio>#include <cmath>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;int num[110];bool cmp(int a,int b){ return a>b;}int main(){ int t; scanf("%d",&t); while (t--){ int n; scanf("%d",&n); int sum = 0; for (int i = 0; i < n-1; ++i){ scanf("%d",&num[i]); sum += num[i]; } int max = -10086; for (int i = 0; i <= 100; ++i){ //用floor取整wa了 if (i*(4*n-3)<=3*sum){ if (i>max) max = i; } } int cnt = 0; for (int i = 0; i < n-1; ++i){ if (num[i] == max){ cnt++; } } printf("%d ",max); printf("%.2lf\n",1.0/(cnt+1)); } return 0;}
阅读全文
0 0
- Make Anonymous be the lucky guy
- A. I Wanna Be the Guy
- 469A - I Wanna Be the Guy
- 【CodeForces】A. I Wanna Be the Guy
- Codeforces I Wanna Be the Guy
- codeforces-#469A. I Wanna Be the Guy(模拟)
- CodeForces 469A. I Wanna Be the Guy(数学)
- Codeforces 469A I Wanna Be the Guy(水题)
- CF 469A I Wanna Be the Guy
- Codeforces 469A I Wanna Be the Guy
- The first guy
- Devu, the Dumb Guy
- CodeForces 469A. I Wanna Be the Guy set简单应用
- B. Devu, the Dumb Guy
- B. Devu, the Dumb Guy
- Guy,Keep your hair on .Whatever will be ,will be.
- I'm the new guy here
- Codeforces 439B Devu, the Dumb Guy
- python-01
- JQ对DOM的操作实例
- myflag step 11SuperviseDao
- 207.Course Schedule
- 从SAP最佳业务实践看企业管理(83)-PP-145按库存生产
- Make Anonymous be the lucky guy
- nginx在linux操作系统上的安装方法
- Qt creator信号与槽的一种方法实现
- HTML基础学习-4-超链接学习
- myflag step 12
- HTML基础学习-5-table表格学习1
- 模块涉及摄像头 文件系统 LCD
- R语言绘图资料
- 存储器的管理模式