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 ...
随机推荐
- R语言操作数据库
以下内容出自http://www.douban.com/note/172387172/ CRAN上有很多R的数据库支持包,使R能够对数据库进行读写操作.这些包有:RODBC.DBI.RMySQL.RO ...
- app内嵌web的一些问题记录
问题(1)webview里面出现大图预览,点击手机上的返回,应该是图片预览消失 问题(2)键盘输入的时候,键盘会把输入框遮挡 ------------------------------------- ...
- Win 7 下制作 mac 系统启动U盘
Win 7 下制作 mac 系统启动U盘 前几天因为工作需要,在mac 上安装了win7.后来因为习惯问题将win7 分区了,后来就是进不去mac os,只能进入win7 .可恶. 苹果客服说只能用m ...
- cocos基础教程(2)Window环境下搭建
第一步:开始安装VS2012 第二步:下载Cocos2d-x 3.4源码 配置环境变量 COCOS_CONTROL = E:\cocos2d-x-3.4\tools\cocos2d-console ...
- Window_搭建SVN服务器
http://wenku.baidu.com/link?url=614FLi_VlhiJpyG5bq8JcwFBHroMjsV3FvBDzyyn0snZ85jbWx7xh-RPJdH7stxlgM9i ...
- [OpenJudge 3061]Flip The Card
[OpenJudge 3061]Flip The Card 试题描述 There are N× Ncards, which form an N× Nmatrix. The cards can be p ...
- [BZOJ3786]星系探索
[BZOJ3786]星系探索 试题描述 物理学家小C的研究正遇到某个瓶颈. 他正在研究的是一个星系,这个星系中有n个星球,其中有一个主星球(方便起见我们默认其为1号星球),其余的所有星球均有且仅有一个 ...
- java中四种阶乘的计算
package com.zf.s2;//创建一个包 import java.math.BigInteger;//导入类 import java.util.ArrayList; import jav ...
- 反弹SHELL
[姿势] http://www.91ri.org/6620.html http://www.waitalone.cn/linux-shell-rebound-under-way.html [图释] h ...
- IOS多线程(NSOperation,NSOperationQueue)
含义:NSOperation,NSOperationQueue是什么. The NSOperation class is an abstract class you use to encapsulat ...