6 solutions

  • 6
    @ 2024-2-23 20:47:37

    非打表,点赞!!!!!!!👀️

    #include<bits/stdc++.h>
    using namespace std;//binary_search
    double f(double x){
        return x*x*x*x*x-15*x*x*x*x+85*x*x*x-225*x*x+274*x-121;
    }
    int main(){
        double r=2.4,l=1.5,mid=(l+r)/2;
        while(r-l>double(1e-10)){
            mid=(r+l)/2;
            if(f(mid)*f(r)<0) l=mid;
            if(f(mid)*f(l)<0) r=mid;
        }
        printf("%.6f",mid);
        return 0;
    }
    
    • @ 2025-3-12 13:47:12

      其实可以直接解高次方程,会分解因式即可(doge)

  • 4
    @ 2024-2-23 20:50:13

    题意

    找在 [1.5,2.4][1.5,2.4] 的根

    根:f(x)=0f(x)=0xx 就是根

    思路

    由于有超精确的小数,所以要用 eps

    二分找就行了

    代码

    #include <bits/stdc++.h>
    #define f(x) (x * x * x * x * x - 15 * x * x * x * x + 85 * x * x * x - 225 * x * x + 274 * x - 121)
    using namespace std;
    const double eps = 1e-8;
    int main(int argc, char **argv){
    	double l = 1.5,r = 2.4;
    	double mid = (l + r) / 2;
    	while (r - l > eps){	// 如果 l 与 r 相差几乎等于 0
    		mid = (l + r) / 2;
    		double x = f(mid) * f(l);
    		if (x < 0)	r = mid;	// 如果根在左区间
    		else if(x > 0)	l = mid;	// 如果根在右区间
    	}
    	printf("%.6f",mid);
    	return 0;
    }
    
    • 0
      @ 2025-3-9 16:40:19
      #include<cstdio>
      #include<cmath>
      #define eps 1e-10
      
      inline double f(double x)
      {
          return pow(x,5)-15*pow(x,4)+85*pow(x,3)-225*pow(x,2)+274*x-121;
      }
      
      double l=1.5,r=2.4,mid,res;
      
      int main()
      {
          while(fabs(l-r)>eps)    //实数判等是比较他们的差值是否小于eps
          {
              mid=l+(r-l)/2;
              res=f(mid);
      
              if(fabs(res)<eps)
              {
                  printf("%.6lf",mid);
                  return 0;
              }
              else if(res<eps)
                  r=mid;
              else
                  l=mid;
          }
          return 0;
      }
      
      • -3
        @ 2024-1-25 9:41:03
        
        
        #include<bits/stdc++.h>
        using namespace std;
        int main(){
        cout << "1.849016" ;
        return 0;
        }
        
        
        
        
        • @ 2024-1-28 16:50:52

          打表垃圾

        • @ 2024-2-23 19:45:37

          打标牛*

        • @ 2024-2-23 20:26:45

          ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????打标???????????????

        • @ 2024-2-23 20:28:39

          垃圾

        • @ 2024-2-23 20:28:44

          垃圾

      • -4
        @ 2024-2-23 21:03:07

        #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int a[maxn];

        int main(){

        int n,m; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; cin>>m; sort(a,a+n);

        { for(int i=0;i<n;i++){ int liu=m-a[i]; if(binary_search(a+i+1,a+n,liu)){ cout<<a[i]<<" "<<liu; return 0;

        }

        } cout << "No" << endl; } }

        • -4
          @ 2024-2-23 21:02:23

          #include <bits/stdc++.h> using namespace std;

          double f(long double x) { return xxxxx-15xxxx+85xxx-225xx+274x-121; }

          int main(){

          long double l=1.5,r=2.4; while(l+1e-9<r){ double mid=(l+r)/2; if(f(l)*f(mid)<0) r=mid; if(f(l)*f(mid)>0) l=mid;

          } cout<<fixed<<setprecision(6)<<l; }

          • 1

          Information

          ID
          726
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          6
          Tags
          # Submissions
          148
          Accepted
          43
          Uploaded By