HDU 5074 Luck Competition (暴力,概率)
题意:有 n 个人参加比赛,给出n-1个人的成绩,然后要选出一个幸运的人,先把所有的分数求平均数,然后再*2/3,那个不大于这个数,且最接近的数,就是最幸运的,
让你设置最后一个人的分,使他是最幸运的。
析:题目说了,最多是100,那么这么少,完全可以暴力啊,然后不断更新最大概率。
代码如下:
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 100 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
char s[maxn][maxn];
int n, m;
int vis[maxn][maxn];
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[maxn]; int main(){
int T; cin >> T;
while(T--){
scanf("%d", &n);
int sum = 0;
for(int i = 1; i < n; ++i){
scanf("%d", &a[i]);
sum += a[i];
}
sort(a+1, a+n);
int indx = 1000;
double ans = 0.0;
int p = -1;
for(int i = 0; i <= 100; ++i){
double t = sum*1.0 + i*1.0;
t = t * 2.0 / 3.0 / (n*1.0);
int tt = (int)t;
if(i > tt) continue;
bool ok = true;
int cnt = 0;
for(int j = n-1; j > 0; --j){
if(a[j] <= tt && a[j] > i){ ok = false; break; }
else if(a[j] == i) ++cnt;
else if(a[j] < i) break;
}
if(!ok) continue;
if(indx >= cnt){
indx = cnt;
p = i;
}
}
printf("%d %.2lf\n", p, 1.0/(indx+1)*1.0);
}
return 0;
}
HDU 5074 Luck Competition (暴力,概率)的更多相关文章
- hdu 5074 Hatsune Miku DP题目
题目传送门http://acm.hdu.edu.cn/showproblem.php?pid=5074 $dp[i][j] =$ 表示数列前$i$个数以$j$结尾的最大分数 $dp[i][j] = - ...
- HDU 6693 Valentine's Day (概率)
2019 杭电多校 10 1003 题目链接:HDU 6693 比赛链接:2019 Multi-University Training Contest 10 Problem Description O ...
- HDU 5074 Hatsune Miku(2014鞍山赛区现场赛E题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5074 解题报告:给出一个长度为n的序列,例如a1,a2,a3,a4......an,然后这个序列的美丽 ...
- dp --- 2014 Asia AnShan Regional Contest --- HDU 5074 Hatsune Miku
Hatsune Miku Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5074 Mean: 有m种音符(note),现在要从 ...
- HDU 3853:LOOPS(概率DP)
http://acm.split.hdu.edu.cn/showproblem.php?pid=3853 LOOPS Problem Description Akemi Homura is a M ...
- HDU 3076 ssworld VS DDD 概率dp,无穷级数,oj错误题目 难度:2
http://acm.hdu.edu.cn/showproblem.php?pid=3076 不可思议的题目,总之血量越少胜率越高,所以读取时把两人的血量交换一下 明显每一轮的胜率和负率都是固定的,所 ...
- [HDU 5074] Hatsune Miku (动态规划)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5074 题目大意是给你m个note,n个数,得分是v[a[i]][a[i+1]]的总和,如果说a[i]是 ...
- HDU 5781 ATM Mechine (概率DP)
ATM Mechine 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5781 Description Alice is going to take ...
- hdu 5461 Largest Point 暴力
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
随机推荐
- Codeforces 445 A DZY Loves Chessboard【DFS】
题意:给出n*m的棋盘,在‘.’处放上B或者W,最后要求所有的B和W都不相邻 先把棋盘的点转化成‘B’,再搜,如果它的四周存在‘B’,则将它变成'W' 一直挂在第五个数据的原因是,没有dfs(nx,n ...
- 通过运行时动态给OC分类添加属性
#import <UIKit/UIKit.h> /** iOS 开发中,分类默认不允许保存属性 如果在分类中,定义一个属性,需要自己实现 getter & setter 方法,而且 ...
- I.MX6 ov5640 camera
/************************************************************************ * I.MX6 ov5640 camera * 说明 ...
- hihoCoder #1179 : 永恒游戏 (暴力枚举)
题意: 给出一个有n个点的无向图,每个点上有石头数个,现在的游戏规则是,设置某个点A的度数为d,如果A点的石子数大于等于d,则可以从A点给每个邻接点发一个石子.如果游戏可以玩10万次以上,输出INF, ...
- MYSQL复制的几种模式
MySQL 5.1 中,在复制方面的改进就是引进了新的复制技术:基于行的复制. MYSQL复制的几种模式 MySQL 5.1 中,在复制方面的改进就是引进了新的复制技术:基于行的复制.简言之,这种新技 ...
- 【英语】Bingo口语笔记(27) - 如何培养口语语感
- 部署HBase远程访问的问题集合(Eclipse)
实现远程访问HBase,可以通过Eclipse开发工具方便进行代码调试. 为了方便jar包各种版本的管理,才用maven进行代码构建 首先,下载并安装maven以及M2Eclipse插件 其次,配置m ...
- 四:分布式事务一致性协议paxos通俗理解
转载地址:http://www.lxway.com/4618606.htm 维基的简介:Paxos算法是莱斯利·兰伯特(Leslie Lamport,就是 LaTeX 中的"La" ...
- selenium python (五)打印信息及设置等待时间
#!/usr/bin/python# -*- coding: utf-8 -*-__author__ = 'zuoanvip' #一般情况下我们要验证打开的页面是否正确,可通过网页的Title和Cur ...
- leetcode:Reverse Integer(一个整数反序输出)
Question:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 ...