hdu 5065 数学题

#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;
}

时间: 2024-10-11 05:48:38

hdu 5065 数学题的相关文章

HDU 5073 数学题

题目传送门 http://acm.hdu.edu.cn/showproblem.php?pid=5073 这道题RE了好多发啊囧,RE到精神不振. Galaxy的质心并不是一成不变的,随着一些星球的移动而变化,最终质心就变成了坐标和的平均值了. 具体思路如右http://mathlover.info/archives/hdu5073 代码就补贴了囧...

hdu 4519(数学题)

郑厂长系列故事——体检 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1361    Accepted Submission(s): 747 Problem Description 郑厂长不是正厂长 也不是副厂长 他根本就不是厂长 只是公司的一个码农 郑厂长所在的腾讯公司每一年都要组织员工体检,比如量身高体重.测血压之类的,今年也不例外.

HDU 1030 数学题

给出两点,求这两点在图上的最短路径 分别以最上,左下,右下为顶点,看这个三角图形 ans=这三种情况下两点的层数差 #include "stdio.h" #include "string.h" #include "math.h" int main() { int n,m,sn,sm,rn,rm,ln,lm,ans; while (scanf("%d%d",&n,&m)!=EOF) { sn=sqrt(n); i

hdu 5241 数学题= =

题意:balabala 题意里给出了好多集合之间的关系,一开始以为要用离散一步一步推什么的... [然而其实并没有什么卵用 对于每一种语言来说,这种语言谁会谁不会是的方案数一定,而且语言之间相互独立的,互相之间通过乘法原理来计算方案数,这样就一定是某一个数的n次方啦~ 由sample data知,答案为32^n 用java写能偷懒[逃 1 import java.io.*; 2 import java.math.*; 3 import java.util.*; 4 public class Ma

hdu 1030 数学题加观察

#include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <cmath> #include <cstring> #include <stack> #include <set> #include <map> #include <vector> using namespace st

hdu 4974 A simple water problem(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4974 Problem Description Dragon is watching competitions on TV. Every competition is held between two competitors, and surely Dragon's favorite. After each competition he will give a score of either 0 or

hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7    Accepted Submission(s): 4 Problem Description Hanamichi is taking part in

hdu 1012:u Calculate e(数学题,水题)

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit

hdu 1299 Diophantus of Alexandria(数学题)

题目链接:hdu 1299 Diophantus of Alexandria 题意: 给你一个n,让你找1/x+1/y=1/n的方案数. 题解: 对于这种数学题,一般都变变形,找找规律,通过打表我们可以发现这个答案只与这个数的因子有关. n=a1^p1*a2^p2*...*an^pn ans=((1+2*p1)*(1+2*p2)*...*(1+2*pn)+1)/2 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=a;i<=b;