#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