当前位置:网站首页>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
边栏推荐
- 372. chessboard coverage
- R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、自定义FUN参数为多个统计量函数名称的列表计算多个统计量
- 企业数据防泄露解决方案分享
- go 语言指针,值引用和指针引用
- Jetpack Compose 最新进展
- Case analysis: using "measurement" to improve enterprise R & D efficiency | ones talk
- RT-thread使用rt-kprintf
- 国内有哪些好的智能家居品牌支持homekit?
- js监听页面或元素scroll事件,滚动到底部或顶部
- [JS] - [string - application] - learning notes
猜你喜欢

当初吃土建起来的“中台”,现在为啥不香了?

#22Map介绍与API

HarmonyOS访问数据库实例(3)--用ORM Bee测下HarmonyOS到底有多牛

Installation and deployment of ganglia

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

伪原创智能改写api百度-收录良好

Harmonyos accessing database instances (3) -- use ORM bee to test how good harmonyos is

7-6 铺设油井管道
![[basic knowledge] ~ half adder & full adder](/img/06/7f1ede65dca527c8630285b587a4ba.png)
[basic knowledge] ~ half adder & full adder
![[JS] - [stack, team - application] - learning notes](/img/5b/b90ed8d3eb4fc0ab41c6ea8d092d0f.png)
[JS] - [stack, team - application] - learning notes
随机推荐
Yyds dry goods counting uses xshell to implement agent function
sql -CONVERT函数
jar中没有主清单属性
golang map clear
#22Map介绍与API
376. 機器任務
Chapter VI skills related to e-learning 5 (super parameter verification)
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、通过双样本t检验分析(双独立样本t检验)来判断倾向性评分匹配后样本中的所有协变量的平衡情况
What you must know about time series database!
Laravel creates a service layer
libnum库简单使用(进制字符串转换)
常用正则表达式
websocket学习
Yyds dry goods inventory tells us 16 common usage scenarios of redis at one go
【js】-【字符串-应用】- 学习笔记
7-2 后序+中序序列构造二叉树
The R language uses the matchit package for propensity matching analysis and match The data function constructs the matched sample set, and performs Welch double sample t-test analysis and double inde
Use of laravel verifier
379. 捉迷藏
Idea creation module prompt already exists