hdu 5753 Permutation Bo
这里是一个比较简单的问题:考虑每个数对和的贡献。先考虑数列两端的值,两端的摆放的值总计有2种,比如左端:0,大,小;0,小,大;有1/2的贡献度。右端同理。
中间的书总计有6种可能。小,中,大。其中有两种对答案有贡献,即1/3的贡献度。加和计算可得到答案。
Permutation Bo
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 693 Accepted Submission(s): 421
Special Judge
We define the expression [condition] is 1 when condition is True,is 0 when condition is False.
Define the function f(h)=∑ni=1ci[hi>hi−1 and hi>hi+1]
Bo have gotten the value of c1∼cn, and he wants to know the expected value of f(h).
For each test case, the first line contains a non-negative integer n(1≤n≤1000), second line contains n non-negative integer ci(0≤ci≤1000).
If the absolute error between your answer and the standard answer is no more than 10−4, your solution will be accepted.
3 2 4 5
5
3 5 99 32 12
52.833333
#include<iostream>
#include<stdio.h>
using namespace std;
int a[];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i=; i<n; i++)
{
scanf("%d",a+i);
}
if(n==)
{
printf("%.6lf\n",(a[]+0.0));
continue;
}
if(n==)
{
printf("%.6lf\n",(a[]+0.0+a[])/);
continue;
}
double ans=0.0;
ans=(a[]+0.0+a[n-]+0.0);
ans/=;
double tmp=0.0;
for(int i=; i<n-; i++)
{
tmp+=(a[i]+0.0);
}
tmp/=;
ans+=tmp;
printf("%.6lf\n",ans); }
return ; }
hdu 5753 Permutation Bo的更多相关文章
- HDU 5753 Permutation Bo (推导 or 打表找规律)
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- hdu 5753 Permutation Bo 水题
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
- 【数学】HDU 5753 Permutation Bo
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为 ...
- hdu-5753 Permutation Bo(概率期望)
题目链接: Permutation Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
- hdu 5753
Permutation Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- HDU 5752 Sqrt Bo (数论)
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...
- HDU 5762 Teacher Bo (暴力)
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geogra ...
- HDU - 5753 多校联萌3-2
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5753 Sample Input Sample Output 6.000000 52.833333 分析 ...
- HDU 5752 Sqrt Bo【枚举,大水题】
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
随机推荐
- 繁华模拟赛 Vicent坐电梯
/*n<=5000这样就不能用O(n)的转移了,而是要用O(1)的转移.注意我们每次的转移都来自一个连续的区间,而且我们是求和区间求和?前缀和!令sum[step][i]表示f[ste ...
- Valid Pattern Lock(dfs + 暴力)
Valid Pattern Lock Time Limit: 2 Seconds Memory Limit: 65536 KB Pattern lock security is genera ...
- poj1012.Joseph(数学推论)
Joseph Time Limit: 1 Sec Memory Limit: 64 MB Submit: 493 Solved: 311 Description The Joseph's prob ...
- TCPIP,Http,Socket的区别
网络由下往上分为 物理层.数据链路层.网络层.传输层.会话层.表示层和应用层. 通过初步的了解,我知道IP协议对应于网络层,TCP协议对应于传输层,而HTTP协议对应于应用层, 三者从本质上来说没有可 ...
- [POJ1157]LITTLE SHOP OF FLOWERS
[POJ1157]LITTLE SHOP OF FLOWERS 试题描述 You want to arrange the window of your flower shop in a most pl ...
- linux 搭建hexo博客
搭建环境: CentOS 6.5 1.安装git的编译包 yum -y install gcc zlib-devel openssl-devel perl cpio expat-devel gette ...
- 【leetcode】Combination Sum
Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combin ...
- DP:Bridging Signals(POJ 1631)
不能交叉的引脚 (这一题的难度在于读题)题目大意:有一堆引脚(signals),左边一排,右边一排,左边从上到下,对应着连接右边的引脚(所有的引脚都被接上),现在引脚之间的连线有交叉,我们要桥接这些交 ...
- sql,联合主键,按id分组求版本号最大值的集合
表结构如下: /* SQLyog v10.2 MySQL - 5.5.39 ************************************************************** ...
- javaScript中利用ActiveXObject来创建FileSystemObject操作文件
注:如果用javascript读本地文件,遇到安全问题. 需在浏览器中进行设置,如下: 工具—> Internet选项->安全->自定义级别->启用“没有标识为安全的A ...