首页 > 其他分享 >递推 1166:求f(x,n)

递推 1166:求f(x,n)

时间:2024-03-30 09:12:20浏览次数:25  
标签:10 1166 4.2 int include 递推 2.5

 

#include<iostream>
#include<cmath>
using namespace std;
int main(){
	float x,n,b=0;
	cin>>x>>n;
	b=sqrt(1+x);
	for(int i=2;i<=n;i++){
		b=sqrt(i+b);
	}
	cout<<b;
	
	
	
	return 0;
}

  

1166:求f(x,n)


时间限制: 1000 ms         内存限制: 65536 KB
提交数:35451    通过数: 23464

【题目描述】

已知

<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 25.553em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(0.302em, 1025.55em, 3.603em, -999.998em); top: -2.298em; left: 0em;"><span class="mrow" id="MathJax-Span-2" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-3" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">f<span style="transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; overflow: hidden; height: 1px; width: 0.053em;">(x,n)=n+(n−1)+(n−2)+...+2+1+x−−−−√−−−−−−−−−−−−−√−−−−−−−−−−−−−−−−−−−−−−√−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−√−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−√�(�,�)=�+(�−1)+(�−2)+...+2+1+�

计算<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 7.003em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(1.203em, 1006.95em, 2.502em, -999.998em); top: -2.147em; left: 0em;"><span class="mrow" id="MathJax-Span-44" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-45" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">x=4.2,n=10�=4.2,�=10以及<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 7.003em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(1.203em, 1006.95em, 2.502em, -999.998em); top: -2.147em; left: 0em;"><span class="mrow" id="MathJax-Span-55" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-56" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">x=2.5,n=15�=2.5,�=15时的<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0.552em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(1.052em, 1000.55em, 2.252em, -999.998em); top: -1.898em; left: 0em;"><span class="mrow" id="MathJax-Span-66" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-67" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">f<span style="transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; overflow: hidden; height: 1px; width: 0.053em;">�的值。

【输入】

输入<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0.552em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(1.302em, 1000.5em, 2.052em, -999.998em); top: -1.898em; left: 0em;"><span class="mrow" id="MathJax-Span-69" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-70" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">x�和<span style="transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; width: 0.603em; height: 0px; font-size: 20px;"><span style="transition: none 0s ease 0s; position: absolute; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; clip: rect(1.302em, 1000.6em, 2.052em, -999.998em); top: -1.898em; left: 0em;"><span class="mrow" id="MathJax-Span-72" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal;"><span class="mi" id="MathJax-Span-73" style="transition: none 0s ease 0s; display: inline; position: static; border: 0px; padding: 0px; margin: 0px; vertical-align: 0px; line-height: normal; font-family: MathJax_Math-italic;">n�。

【输出】

函数值,保留两位小数。

【输入样例】

4.2 10

【输出样例】

3.68

提交 统计信息

标签:10,1166,4.2,int,include,递推,2.5
From: https://www.cnblogs.com/wangyueshuo/p/18105017

相关文章

  • 2990: 【C3】【递推】蟠桃记
    题目描述喜欢西游记的同学肯定都知道悟空偷吃蟠桃的故事,你们一定都觉得这猴子太闹腾了,其实你们是有所不知:悟空是在研究一个数学问题! 什么问题?他研究的问题是蟠桃一共有多少个! 不过,到最后,他还是没能解决这个难题,呵呵^-^ 当时的情况是这样的: 第一天悟空吃掉桃子总数一半......
  • C++U4- 04 - 新递推2
     排列 公式 单选 组合数 单选 递推练习[直线分割平面问题]   【参考代码】#include<iostream>usingnamespacestd;inta[1010];//a[i]:第i条直线最多能将这个圆分割成的部分数intmain(){//1、定义变量n,进行输入,数组a进行存储......
  • 线性递推公式的矩阵快速幂技巧
    快速幂顾名思义,快速幂是指快速求解幂运算的技巧。正常求\(a^n\)的值需要执行n次相乘操作,而快速幂能在\(log_2n\)时间复杂度内完成。以求\(a^{27}\)为例,27=1+2+8+16,根据乘法结合律可得\(a^{27}=a^1*a^2*a^8*a^{16}\),即只需要指数转化为二进制并且求得对应位是1的幂再累计......
  • 蓝桥杯——盾神与格子游戏(动态规划+递推)
    资源限制内存限制:256.0MB C/C++时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s问题描述在盾神很小很小还不会怎样编程的时候,他迷上了一款风靡一时的双人游戏!游戏双方在地上画n个格子,然后在最后一格放上一颗石头。每人每轮可以把石头向前移动1到3格,最后谁把......
  • 杭电OJ递推系列的题目
    1.2047阿牛的EOF牛肉串阿牛的EOF牛肉串分析:对于这种递推求解的题目无非分为两种递推方式:(1)从前往后递推(2)从后往前递推这道题用从后往前递推比较好,因为题目中的限制条件为禁止出现O相邻的情况,所以通过定后一项的值来判断前一项的取值比较容易。参考资料PS:这种题目难点就......
  • (蓝桥)递归与递推
    1、对于 scanf printf和cincout按照10^5来划分使用 递归实现指数型枚举 https://www.acwing.com/problem/content/94/ #include<iostream>#include<cstring>#include<cstdio>#include<algorithm>usingnamespacestd;constintN=17;intn;inta[N];......
  • 洛谷题单指南-递推与递归-P1498 南蛮图腾
    原题链接:https://www.luogu.com.cn/problem/P1498题意解读:观察样例,可以发现,当n=1时,得到最基础的图案:/\/__\当n=2时,将基础图案向下复制两个,并排,然后将之前的图案移到居中的位置/\/__\/\/\/__\/__\当n=3时,再将n=2时的图案向下复制两个,并排,然后将之前的图......
  • 洛谷题单指南-递推与递归-P1228 地毯填补问题
    原题链接:https://www.luogu.com.cn/problem/P1228题意解读:用4种毯子铺满2^k*2^k的区域,留出一个公主位置,输出所有毯子拐角的坐标以及哪种毯子,看起来有点无从下手,可以从k=1,k=2,k=3入手去依次考虑,找到规律,用分治法解决。解题思路:1、当k=1时,即2*2的区域,对于任意一个位置是公主,都......
  • 洛谷题单指南-递推与递归-P1010 [NOIP1998 普及组] 幂次方
    原题链接:https://www.luogu.com.cn/problem/P1010题意解读:输出一个正整数的2的幂次方表示,需要用到二进制数学知识,将整数拆解成2的次幂之和,幂次方也要进行拆解,因此容易想到通过递归处理。解题思路:先看样例,给定整数137,要拆解成2的幂次方之和,先考虑i使得刚好137>=2^i时,i取7,因此2......
  • 洛谷题单指南-递推与递归-P1259 黑白棋子的移动
    原题链接:https://www.luogu.com.cn/problem/P1259题意解读:要打印最终的状态,关键在找到一些变化的规律,直接的暴力搜索复杂度太高。解题思路:从样例出发ooooooo*******--oooooo--******o*oooooo******--o*ooooo--*****o*o*ooooo*****--o*o*oooo--****o*o*o*oooo****--o*o*o*ooo--......