当前位置:网站首页>7-8 ladder cloud vertical
7-8 ladder cloud vertical
2022-06-24 23:31:00 【White -】
7-8 Echelon of clouds
After Newton announced that the Chinese film and television city was not under his control , cross * Tiyunzong can take off in situ and go straight to the moon . Suppose horizontal * It's only... From the moon n rice , And horizontal * A slow motion with the left foot and the right foot can increase the probability 1 rice perhaps 2 rice . Please calculate his steps to the moon .
Be careful , When he was only... Away from the moon 1 Rice is , He will 100% The probability of choice rises 1 rice .
set up X The probability of walking to the moon P(X) by , The number of steps to land on the moon is expected =∑ X=0n P(X)∗X
Input format :
In the first line, enter the number of sample groups t(1<=t<=100)
After that t That's ok , Each line gives a positive integer n(1<=n<=10 5) Indicates horizontal * The moon has n rice
Output format :
For each set of data , Output the expected number of steps to the moon in one line , Rounding reservation 6 Decimal place .
sample input :
Here's a set of inputs . for example :
3
1
2
3
sample output :
Here is the corresponding output . for example :
1.000000
1.500000
2.250000
Code :
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int n;
double a[110000];
double mid[110000];
double getmid(int x)// Return difference
{
if(mid[x]!=0)
return mid[x];
else
return mid[x]=(getmid(x-1)+getmid(x-2))/2;
}
double geta(int x)
{
if(a[x]!=0)
return a[x];
else
return a[x]=geta(x-1)+getmid(x-1);
}
double change(double x)
{
if(x<10000)
return x;
return x+0.0000002;
}
int main()
{
scanf("%d",&n);
int x;
a[0]=0;
a[1]=1;
a[2]=1.5;
a[3]=2.25;
//a[4]=2.875;
mid[0]=a[1]-a[0];
mid[1]=a[2]-a[1];
mid[2]=a[3]-a[2];
//mid[3]=a[4]-a[3];
for(int i=0;i<n;i++)
{
scanf("%d",&x);
double z=geta(x);
printf("%lf\n",change(z));
}
return 0;
}
Tips :
20% The data of ,1<=n<=10
40% The data of ,1<=n<=10 2
60% The data of ,1<=n<=10 4
100% The data of ,1<=n<=10 5
202206222107 3、 ... and
边栏推荐
- 还在用 SimpleDateFormat 做时间格式化?小心项目崩掉
- Quickly build KVM virtual machine on # yyds dry goods inventory # physical machine
- sql -CONVERT函数
- 【UVM入门 ===> Episode_8 】~ Sequence 和 Sequencer、Sequence 层次化
- 7-3 最大子段和
- Actipro WPF Controls 2022.1.2
- Ganglia 的安装与部署
- Simple use of libnum Library (hexadecimal string conversion)
- [JS] - [array application] - learning notes
- 基于三维GIS开发的水电工程建设方案
猜你喜欢
![[JS] - [linked list - application] - learning notes](/img/e1/76d2a347b05212de349322f43e0b3a.png)
[JS] - [linked list - application] - learning notes

慕思股份深交所上市:靠床垫和“洋老头”走红 市值224亿

Quickly build KVM virtual machine on # yyds dry goods inventory # physical machine

2021-2022 China's financial digitalization "new" insight Industry Research Report

一文理解OpenStack网络

Volcano成Spark默认batch调度器

Continuous soul torture from two MySQL indexes of interviewers

宁德时代定增450亿:高瓴认购30亿 曾毓群仍控制23%股权

企业数据防泄露解决方案分享

Installing IBM CPLEX academic edition | CONDA installing CPLEX
随机推荐
golang convert json string to map
[JS] - [tree] - learning notes
MySQL semi sync replication
RT-thread使用rt-kprintf
7-5 最大子矩阵和问题
idea创建模块提示已存在
libnum库简单使用(进制字符串转换)
明天就是PMP考试了(6月25日),这些大家都了解了吗?
#22Map介绍与API
golang map clear
Case analysis: using "measurement" to improve enterprise R & D efficiency | ones talk
Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity
R语言dplyr包select函数将dataframe数据中的指定数据列移动到dataframe数据列中的第一列(首列)
Installing IBM CPLEX academic edition | CONDA installing CPLEX
Simple use of libnum Library (hexadecimal string conversion)
Fibonacci
Main cause of EMI - mold current
【基础知识】~ 半加器 & 全加器
【js】-【数组、栈、队列、链表基础】-笔记
The R language uses the matchit package for propensity matching analysis and match The data function constructs the matched sample set, and judges the balance of all covariates in the sample after the