博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Random Sequence 2011ACM福州赛区网络赛
阅读量:7105 次
发布时间:2019-06-28

本文共 1622 字,大约阅读时间需要 5 分钟。

Random Sequence

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 202    Accepted Submission(s): 124

Problem Description
There is a random sequence L whose element are all random numbers either -1 or 1 with the same possibility. Now we define MAVS, the abbreviate of Maximum Absolute Value Subsequence, to be any (if more than one) subsequences of L whose absolute value is maximum among all subsequences. Given the length of L, your task is to find the expectation of the absolute value of MAVS.
 

Input
There is only one input file. The first line is the number of test cases T. T positive integers follow, each of which contains one positive number not greater than 1500 denoted the length of L.
 

Output
For each test case, output the expectation you are required to calculate. Answers are rounded to 6 numbers after the decimal point.(as shown in the sample output)
 

Sample Input
3 1 5 10
 

Sample Output
Case 1: 1.000000 Case 2: 2.750000 Case 3: 4.167969
 

Source
 

Recommend
lcy
 
 
数论神题啊!!!!
卡特兰数
#include
#include
#include
#include
using namespace std; long double a[2000]; long double p; long double C(int n){
long double t=1; for(int i=n+1;i<=2*n+1;i++){
t*=i; t/=i-n; } // for(int i=1;i<=n+1;i++) t/=i; return t; } int main(){
int t,n,cnt=0; a[1]=1; for(int i=2;i<=1500;i++){
if(i%2==0) a[i]=(a[i-1]*2+C(i/2-1)); else a[i]=(a[i-1]*2+C(i/2-1)*2); //cout<<"i="<
<<","<
<
>t; while(t--){ cin>>n; p=pow(2.0,n-1); cout<<"Case "<<++cnt<<": "<
<
<

转载地址:http://hvkhl.baihongyu.com/

你可能感兴趣的文章
Android开发之无侵入式修改TabLayout tabIndicator宽度
查看>>
浅谈 js 中的 this 指向问题
查看>>
C/C++
查看>>
Android中的IPC方式——Binder(一)
查看>>
对Docker的了解,你能读懂多少?
查看>>
PHP Socket 网络编程
查看>>
关于数据库事务并发的理解和处理
查看>>
SQL基本增删改查语句
查看>>
Android Notification
查看>>
vue+vant同一项目实现豆瓣电影加网易云音乐webapp-最佳练手项目
查看>>
springboot activiti 整合项目框架源码 shiro 安全框架 druid 数据库连接池
查看>>
Java开发必须要掌握的21个核心技术
查看>>
数据结构与算法的重温之旅(一)——复杂度分析
查看>>
debounce防抖函数之lodash
查看>>
Spring Cloud微服务分布式云架构 - 整合企业架构的技术点
查看>>
5分钟 0元搭建个人独立博客网站 Hexo+Github pages
查看>>
一个 react 的小项目方便查看 github 上的笔记
查看>>
当无人编辑坐镇新闻编辑部?未来人机社会共存指南
查看>>
git命令
查看>>
JavaScript是如何工作的:渲染引擎和优化其性能的技巧
查看>>