3 条题解

  • 3
    @ 2024-4-3 19:48:06

    😄 我又来发题解啦 我写这道题的时候真™难,足足交了五六遍,操! 这个图有点难看懂 image 先要确定结束条件 是什么~~~~

    自然是image

    好好好,现在我们要确定n不是1是该干甚么 image 它是这样往下套的

    那么是~~~~~~~

    x/(n+what)

    那么该想想what是甚么

    就是f(x,n-1)毕竟x不变嘛~ 好了,说了这么多的废话,上代码

    #include<bits/stdc++.h>
    using namespace std;
    double j(double x,double n){
    	if(n==1) return x/(x+1);
    	else{
    		return x/(n+j(x,n-1));
    	}
    }
    int main(){
    	double a,b;
    	cin>>a>>b; 
    	cout<<fixed<<setprecision(2)<<j(a,b);
    	return 0;
    }
    

    禁止抄奥!!!!

  • -2
    @ 2024-4-13 20:27:18

    我又来发题解啦 我写这道题的时候真™难,足足交了五六遍,操! 这个图有点难看懂。好了,话不多说,上代码! #include<bits/stdc++.h> using namespace std; double j(double x,double n){ if(n==1) return x/(x+1); else{ return x/(n+j(x,n-1)); } } int main(){ double a,b; cin>>a>>b; cout<<fixed<<setprecision(2)<<j(a,b); return 0; } 请勿抄袭哈!

    • -2
      @ 2024-4-3 21:44:54

      题目的重点在于“x/(n+未知)”中的“未知”。 这个“未知”就是“f(x,n-1)”。 所以,正确代码如下: #include #include using namespace std; double f(double x,long long n) { if(n==1) { return x/(1+x); } else { return x/(n+f(x,n-1)); } } double x; long long n; int main() { cin>>x>>n; cout<<fixed<<setprecision(2)<<f(x,n); return 0; }

      • 1

      信息

      ID
      492
      时间
      1000ms
      内存
      128MiB
      难度
      6
      标签
      递交数
      115
      已通过
      32
      上传者