Strange fuction--hdu2899
Strange fuction
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4538 Accepted Submission(s):
3261
F(x) = 6 *
x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)
Can you find the minimum value
when x is between 0 and 100.
T(1<=T<=100) which means the number of test cases. Then T lines follow,
each line has only one real numbers Y.(0 < Y <1e10)
places),when x is between 0 and 100.
#include<stdio.h>
#include<math.h>
double hs(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x*x-y*x;//定义一个求函数值得函数
}
double ds(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x-y;//定义一个求导数的函数
}
int main()
{
int a;
scanf("%d",&a);
while(a--)
{
double b,x,y,z;
scanf("%lf",&b);
x=0.0;
y=100.0;
do
{
z=(x+y)/;
if(ds(z,b)>)
y=z;
else
x=z;
}while(y-x>1e-);//求出一定精度内导数为0的大约值
printf("%.4lf\n",hs(z,b));
}
return ;
}
#include<stdio.h>
#include<math.h>
double hs(double x,double y)
{
return *pow(x,)+*pow(x,)+*pow(x,)+*x*x-y*x;
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
double l,r,mid,midmid,a;
scanf("%lf",&a);
l=0.0;
r=100.0;
do
{
mid=(l+r)/;
midmid=(mid+r)/;
if(hs(mid,a)>hs(midmid,a))
l=mid;
else
r=midmid;
}while(r-l>1e-);
printf("%.4lf\n",hs(mid,a));
}
return ;
}
Strange fuction--hdu2899的更多相关文章
- 【精度问题】【HDU2899】Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU2899 Strange fuction 【二分】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- ACM : HDU 2899 Strange fuction 解题报告 -二分、三分
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others ...
- hdoj 2899 Strange fuction【二分求解方程】
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- Strange fuction
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- hdu 2899 Strange fuction (二分法)
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- Strange fuction hdu 2899
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu2899 Strange fuction
在区间(0,100).在恒大二阶导数0.f(x)有极小值.用的最低要求的一阶导数值点: #include<math.h> #include<stdio.h> #include& ...
- Strange fuction
Problem Description Now, here is a fuction: F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=1 ...
随机推荐
- PHP读取EXCEL时写入数据乱码解决办法
第一步排除excel读取的数据是不是乱码 EXCEL读取时经常会出现乱码,而我们常用的字符集是UTF-8 ,GB2312(GBK) ,这就需要对编码进行转换,但是又不能对纯数字和英文字符转换,否则会乱 ...
- H5本地存储
在HTML5中可以把数据长期存储在客户端,使用的对象就是localStorage. localStorage常用方法有setItem.getItem.removeItem.clear. 下面是一个存储 ...
- python 核心编程第六章课后题自己做的答案
6–6. 字符串.创建一个 string.strip()的替代函数:接受一个字符串,去掉它前面和后面的 空格(如果使用 string.*strip()函数那本练习就没有意义了) 'Take a str ...
- Roads in the North(POJ 2631 DFS)
Description Building and maintaining roads among communities in the far North is an expensive busine ...
- NOI十连测 第四测 T2
思路:线段树套可持久化treap,可持久化treap我还是第一次听说.. 改题的时候没看数据范围..乱开数组T_T #include<algorithm> #include<cstd ...
- GUI为什么不设计为多线程(用户事件和底层事件的流程是相反的,每层都加锁效率太低,共用一把锁那就是单线程)
在我们这批新人转正评审的时候,我师父问了我的小伙伴一个问题:为什么一些更新界面的方法只能在主线程中调用?师父没有问我这个问题,让知其然但不知其所以然的我有种侥幸逃过一难的心情.我想如果回答那是因为An ...
- tomcat7 https 成功测试
1,生成证书
- PSPInstance Object | Web Python
PSPInstance Object | Web Python The PSPInstance object is available to all PSP pages through the psp ...
- 04747_Java语言程序设计(一)_第2章_运算和语句
推荐使用f2 public class Aserver { public static void main(String args[]) { float f1 = (float) 12.345; fl ...
- Unity position和localposition
1. position是根据世界原点为中心 2. localPosition是根据父节点为中心,如果没有父节点,localpositon和position是没有区别的 3.选中一个物体左上角Globa ...