【数学】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为真则为1,假为0.
函数f(h)=(i=1~n)∑ci[hi>hi−1 && hi>hi+1]
现在给定c的值,求f(h)的期望。
题目思路:
【数学】
头尾的概率为1/2,中间的概率为1/3,直接求和。
//
//by coolxxx
//
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define eps (1e-8)
#define J 10000000
#define MAX 0x7f7f7f7f
#define PI 3.1415926535897
#define N 1004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int c[N];
double s;
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,l,r,x;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
// while(~scanf("%s",s))
while(~scanf("%d",&n))
{
s=;
for(i=;i<=n;i++)
scanf("%d",&c[i]);
s+=(c[]+c[n])/2.0;
for(i=;i<n;i++)
s+=c[i]/3.0;
printf("%lf\n",s);
}
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
这里是一个比较简单的问题:考虑每个数对和的贡献.先考虑数列两端的值,两端的摆放的值总计有2种,比如左端:0,大,小:0,小,大:有1/2的贡献度.右端同理. 中间的书总计有6种可能.小,中,大.其中有 ...
- 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 5761 Rower Bo
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 题目大意: 船在(0,a),船速v1,水速v2沿x轴正向,船头始终指向(0,0),问到达(0, ...
- Permutation Bo (数学证明)
当在两端时:共有n * (n - 1)种组合,满足条件的有,计算可得, counter = n * (n - 1) / 2. 其他位置时:共有n * (n - 1) * (n - 2) 种组合,满足条 ...
- 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 ...
随机推荐
- [转] C++虚函数与虚函数表
http://www.cnblogs.com/Ripper-Y/archive/2012/05/15/2501930.html http://blog.csdn.net/haoel/article/d ...
- 如何参与一个GitHub开源项目
Github作为开源项目的著名托管地,可谓无人不知,越来越多的个人和公司纷纷加入到Github的大家族里来,为开源尽一份绵薄之力.对于个人来讲,你把自己的项目托管到Github上并不表示你参与了Git ...
- VB 活动添加item元素
'ListView1.Columns.Clear() 'ListView1.Columns.Add("", 0, HorizontalAlignment.Center) 'List ...
- C# WebService 基础实例
1.整个Demo结构:如下图: 2.新建项目--选择asp.net web服务应用程序TestWebService 3.重新命名Service1.asmx为MyService.asmx 4.右键MyS ...
- oracle中使用minus进行数据排除(类似SqlServer except函数)
minus这个集合操作符号的作用是从一个结果集合中减掉另一个结果集中数据,也就是说从一个结果集中去除两个结果集中的共有部分. 下面是一些例子: 这个例子使用minus从第一个结果集中将两个结果集的公有 ...
- jquery val() and text().
.val() works on input elements (or any element with a value attribute?) and .text() will not work on ...
- java mail 使用 gmail smtp 发送邮件
smtp 服务器:smtp.gmail.com 使用ssl的端口:465 用户名:username@gmail.com 密码:password** 基本配置没有问题,关键在于Google对安全性要求非 ...
- struts2与spring集成时,关于class属性及成员bean自动注入的问题
http://blog.csdn.net/sun_zhicheng/article/details/24232129
- EBS基础—表的后缀
1._ALL或无后缀:基表,所有对数据操作最终都是对基表的操作,表包含所有不同经营单位的信息,多组织环境. 2._B/_T:也是一种基表.一些数据和验证存储在此表中. 3._TL:语言的基表,TL表支 ...
- linux术语解析(持续更新)
1.linux内核有个版本,分别是 longterm: 提供长期支持的内核版本 stable: 稳定版本 Beta 测试版