zoukankan      html  css  js  c++  java
  • hdu 2199

    基本的二分,但是我还是提交了几次,因为那个er开大了,超时了……

    #include "stdio.h"
    #include "math.h"
    #define er 1e-4//这里的er我起初开到了1e-7……超时了……

    int main()
    {
     int T;
     double n,t,u,d,a;

     scanf("%d",&T);
     while(T--)
     {
      scanf("%lf",&n);

      n=n-6;
      if(n<0||n>(8*10000-100+3)*101*100)
      {
       printf("No solution!\n");
       continue;
      }

      if(n==0)
      {
       printf("0.0000\n");
       continue;
      }

      a=(8*2500-50+3)*51*50;
      t=50;
      u=0;
      d=100;
      while(fabs(a-n)>er)
      {
       if(a-n>0)
       {
        d=t;
        t=(t+u)/2;
       }
       else
       {
        u=t;
        t=(t+d)/2;
       }
       a=(8*t*t-t+3)*(t+1)*t;//这个式子是我化简后的……
      }

      printf("%.4lf\n",t);
     }
     return 0;
    }
        

  • 相关阅读:
    javascript基础
    杂谈
    六大设计原则
    MVC的理解
    不错的资源哦
    平时你从哪里获取前端知识?
    网站背景平铺
    js 获取节点
    自适应后的页面用户点击后会放大
    innerHTML的运用
  • 原文地址:https://www.cnblogs.com/Shirlies/p/2357966.html
Copyright © 2011-2022 走看看