hdu-5753 Permutation Bo(概率期望)
题目链接:
Permutation Bo
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
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.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef unsigned long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e7+10;
const int maxn=1000+10;
const double eps=1e-8; int c[1100]; int main()
{
int n;
while(cin>>n)
{
For(i,1,n)
{
read(c[i]);
}
double ans=0;
for(int i=2;i<n;i++)
{
ans=ans+c[i]*1.0/3;
}
ans=ans+(c[1]+c[n])*1.0/2;
printf("%.6lf\n",ans);
} return 0;
}
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
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为 ...
- 2019杭电多校第七场 HDU - 6656 Kejin Player——概率&&期望
题意 总共有 $n$ 层楼,在第 $i$ 层花费 $a_i$ 的代价,有 $pi$ 的概率到 $i+1$ 层,否则到 $x_i$($x_i \leq 1$) 层.接下来有 $q$ 次询问,每次询问 $ ...
- hdu 5036 Explosion(概率期望+bitset)
Problem Description Everyone knows Matt enjoys playing games very much. Now, he to N. Input The firs ...
- HDU 4576 Robot (概率 & 期望)
Robot Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Sub ...
- hdu 5753
Permutation Bo Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 【BZOJ-1419】Red is good 概率期望DP
1419: Red is good Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 660 Solved: 257[Submit][Status][Di ...
随机推荐
- OpenGL中FBO的概念及其应用 [转]
http://www.cppblog.com/kongque/archive/2010/08/26/124754.html FBO一个最常见的应用就是:渲染到纹理(render to texture) ...
- MachineLearningInAction
2017-01-07 20:14:45 前面两周主要都是在复习然后考试,每天其实过得也挺苦逼的.基本上项目和学习上的是都没有接触了:复习了随机过程和数字信号处理和信号检测和估值:主要都是复习一些理论上 ...
- 【KMP】hdu1867(A + B for you again) 杭电java a题真坑
点击打开链接 Problem Description Generally speaking, there are a lot of problems about strings processing. ...
- C语言-二维背包问题
二维费用背包问题 问题: 二维费用的背包问题是指:对于每件物品,具有两种不同的费用:选择这件物品必须同时付出这两种代价:对于每种代价都有 一个可付出的最大值(背包容量).问怎样选择物品可以得到最大的价 ...
- ffmpeg rtmp 推流错误WriteN, RTMP send error 10053 10038
利用ffmepg推264流到rtmp服务端出现错误WriteN, RTMP send error 10053,具体如下图所示. 图1推流到rtmp服务错误 原因是视频流缺少SPS,PPS信息,加上这两 ...
- 如何获得(读取)web.xml配置文件的參数
參考代码例如以下: com.atguigu.struts2.app.converters.DateConverter.java public DateFormat getDateFormat(){ i ...
- DDR 布线规则
https://blog.csdn.net/cpf099/article/details/52038862 https://blog.csdn.net/cpf099/article/details/5 ...
- 深度解析开发项目之 02 - 使用VTMagic实现左右滑动的列表页
深度解析开发项目之 02 - 使用VTMagic实现左右滑动的列表页 实现效果: 01 - 导入头文件 02 - 遵守代理协议 03 - 声明控制器的属性 04 - 设置声明属性的frame 05 - ...
- Google Chrome的快捷键
1.Ctrl + N 打开一个新窗口 && Alt + F4 关闭当前窗口 2.Ctrl + T 打开一个新的标签页 && ...
- PowerDesigner逆向工程,从SQL Server数据库生成Physical Model -----数据源方式
1.File-Reverse Engineer-Database 2.DBMS选择SQL Server 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 一路Next..... ...