hdu 5065 數學題,hdu5065

來源:互聯網
上載者:User

hdu 5065 數學題,hdu5065

#include<iostream>#include<cmath>#include<cstdio>using namespace std;int A,B,y;double ans=0;double inline f(double x){   return A*x*x-(B*sin(x)+y);}double inline absf(double x){    if(f(x)<0)return -f(x);    return f(x);}bool findans(double l,double r)         //求絕對值後函數必然先減後增。三分{    if(f(l)*f(r)>0)return 0;    while(r-l>0.00000001)       //注意精度    {        double mid1=l+(r-l)/3,mid2=r-(r-l)/3;        if(absf(mid1)<=absf(mid2))            r=mid2;        else           l=mid1;    }    ans=l;    return 1;}int main(){   int T;   scanf("%d",&T);   while(T--)   {      scanf("%d%d%d",&A,&B,&y);      bool marks=0;ans=0;      for(double x=0;x<50;x=x+0.3)      {          if(findans(x,x+0.3))          {              marks=1;break;          }      }      if(marks)          printf("%.5lf\n",ans);      else          printf("error\n");   }   return 0;}


hdu4159,很水很水的一道數學機率題,誰幫忙看下

若n(排隊的人)>s(Indomie) 100%
s==0, 0%
其他情況,設Ai為i個人選Indomie的事件總數
那麼 Ai=C(n,i) /*n個人i各選Indomie*/ * 2^(n-i) /* 其餘人可能選rice 或者 sugar */
還有Indomie剩下的機率為 ΣAi(i=0,1,2,…s-1) / ΣAi(i=0,1,2,…, s);
 
HDU 1071簡單的數學用積分面積我下面的程式什地方有問題指教或者還有什更好的方法?

按acm.hdu.edu.cn/showproblem.php?pid=1071的要求,是求陰影的面積

拿你的程式運行一下:
1
5 5 0 0 10 0
33.33 <======正確
再次運行
1
5 10 0 5 10 5
83.33 <======錯誤
第二次的P1 P2 P3三點是把第一次的三點上移5個單位,各點相對位置不變,面積也不會變
83.33-53.33=50= 5X10 ,就是說你把空白面積加進來了,

解決辦法:減去P2P3和x軸之間的梯形面積
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.