hdu 2899 Strange fuction (二分法)】的更多相关文章

Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2278    Accepted Submission(s): 1697 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 <=…
http://acm.hdu.edu.cn/showproblem.php?pid=2899 Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4865    Accepted Submission(s): 3468 Problem Description Now, here is a fuction:  F…
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5933 Accepted Submission(s): 4194 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 <=100) C…
题目链接:http://acm.hdu.edu.cn/showproblem.pihp?pid=2899 题目大意:找出满足F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)的x值.注意精确度的问题. 求满足条件的x的最小值!!求导,利用单调性来找到最小值. #include <iostream> #include <cstdio> #include <cmath> using namespace std;…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 还可三分.不过只写了模拟退火. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<ctime> #include<cmath> #include<cstdlib> #define db double using…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2899 模拟退火: 怎么也过不了,竟然是忘了写 lst = tmp ... 还是挺容易A的. 代码如下: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<cstdlib> #include<…
三分可以用来求单峰函数的极值. 首先对一个函数要使用三分时,必须确保该函数在范围内是单峰的. 又因为凸函数必定是单峰的. 证明一个函数是凸函数的方法: 所以就变成证明该函数的一阶导数是否单调递增,或者其二阶导数是否大于0. #include<stdio.h> #include<math.h> ; double js(double x,double y){ *pow(x,)+*pow(x,)+*pow(x,)+*pow(x,)-y*x; } int main(){ int n; do…
求  F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100)的最小值 模拟退火,每次根据温度随机下个状态,再根据温度转移 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> #define inf (double)0x3f3f3f3f3f3f3f3fll usi…
题目链接 \(Description\) 求函数\(F(x)=6\times x^7+8\times x^6+7\times x^3+5\times x^2-y\times x\)在\(x\in \left[0,100\right]\)时的最小值. \(Solution\) \(x\geq 0\)时\(F(x)\)为单峰凹函数,三分即可. 而且由此可知\(F(x)\)的导数应是单增的.函数最值可以转化为求导数零点问题,于是也可以二分求\(F'(x)\)的零点,或者用牛顿迭代求. 峰值函数最值也可…
1.题意:给一个函数F(X)的表达式,求其最值,自变量定义域为0到100 2.分析:写出题面函数的导函数的表达式,二分求导函数的零点,对应的就是极值点 3.代码: # include <iostream> # include <cstdio> # include <cmath> using namespace std; ; double Y; int sgn(double x) { ; ) ; ; } double F(double x) { )+)+)+)-Y*x;…
Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4599    Accepted Submission(s): 3304 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 <=…
Problem Description Now, here is a fuction: F(x) = 6 * x^7+8x^6+7x^3+5x^2-yx (0 <= x <=100) Can you find the minimum value when x is between 0 and 100. Input The first line of the input contains an integer T(1<=T<=100) which means the number o…
Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4803    Accepted Submission(s): 3428 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 <=…
Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3809    Accepted Submission(s): 2760 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 <…
Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 661 Accepted Submission(s): 544   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 <=100)C…
Strange fuction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2982    Accepted Submission(s): 2202 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 <…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2899 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4802    Accepted Submission(s): 3427 Problem Description Now, here is a fuction:  F(x) = 6 * x^…
本题是一道二分题,但是要利用导数来求最小值.对原函数进行求导,得到的导函数为f(x)=42*pow(x,6)+48*pow(x,5)+21*pow(x,2)+10*x-y;因为0<=x<=100,所以当 y>46802200时,f(x)恒小于0,故F(x)单调递减.当y<46802200时,可知原函数先递减后递增,因此可利用二分找到导函数为零的x的值,再将此x带入原函数就可以得到最小值. #include"iostream" #include"stdi…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4768 题目大意:每组数据有n行输入,每行有三个数A.B.C,A<=B且小于2^32,从A到B每隔C个数发一份传单,最后所有发过传单的数中每一个数发了奇数次传单的是倒霉的那个人,倒霉的人最多只有1个.如果存在这个人输出他的序号和传单数,否则输出“DC Qiang is unhappy” Sample Input 2 1 10 1 2 10 1 4 5 20 7 6 14 3 5 9 1 7 21 12…
http://acm.hdu.edu.cn/showproblem.php?pid=1882 感觉非常不错的一道题. 给一个n*m(1<=n,m<=16)的矩阵,每一个格子都有黑白两面,当翻一个格子时,它的上下左右都要翻转,问最后使格子全变为白色的最少翻转步数. 仅仅需枚举第一行的状态即可,由于对于第i(i>=2)行j列翻转情况受上一行的制约,仅仅有当上一行也是'X'的时候,该行j列才干翻转,使i-1行j列变为'.',否则i行j列不能翻转.依次进行下去,当最后一行全变为白色,说明翻转成功…
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 <=100) Can you find the minimum value when x is between 0 and 100. Input The first line of the input contains an integer T(1<=T<=100) which means the nu…
Cable master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1428    Accepted Submission(s): 522 Problem Description Inhabitants of the Wonderland have decided to hold a regional programming con…
有起点和终点,有方向,有最少次数,所以这道题很明显是一道bfs的题目,这题要利用vist数组来标记已走过的楼层,因为这题里面已走过的楼层是不可能在走第二遍的. 第二次走和第一次走的选择没有任何的区别. #include"iostream" #include"stdio.h" #include"string.h" #include"algorithm" #include"cmath" #include&quo…
题意:给了你一个函数,然后给了你x的变化范围,让你求出函数的最小值. 分析:它让你求的是函数的最小值,所以我们可以先对函数求导,得到的导数就可以判断函数的单调性了,求出导数后,我们发现如果函数的导数是x越大所求的的导数也就越大, 当导数一直为负数时,函数是单调递减的:当导数开始是负数,然后是正数,那说明函数开始时递减的然后是递增的,那么当导数为0时函数值肯定是最小的!我们求导数为0的 过程,我们可以用二分实现! 代码实现: #include<stdio.h> #include<strin…
题目链接 题意 : 给你一个矩阵,有黑有白,翻转一个块可以让上下左右都翻转过来,问最少翻转多少次能让矩阵变为全白. 思路 : 我们从第一行开始枚举要翻转的状态,最多可以枚举到2的16次方,因为你只要第一行的确定了,第二行要翻转的也就确定了,所以第一行的状态决定了最后的状态.看了网上大神,真是让位运算废了啊,,,,,太复杂了...... #include <iostream> #include <stdio.h> #include <string.h> #include…
My birthday is coming up and traditionally I’m serving pie. Not just one pie, no, I have a number N of them, of various tastes and of various sizes. F of my friends are coming to my party and each of them gets a piece of pie. This should be one piece…
hdu2899 : 水提,直接三分,事实上求导后二分也能够. #include<iostream> #include<cstdio> using namespace std; double y; double inline f( long double x) { return 6*x*x*x*x*x*x*x+8*x*x*x*x*x*x+7*x*x*x+5*x*x-y*x; } int main() { int T;scanf("%d",&T); whil…
在区间(0,100).在恒大二阶导数0.f(x)有极小值.用的最低要求的一阶导数值点: #include<math.h> #include<stdio.h> #include<stdlib.h> #include<string.h> const double eps=1e-6; double f(double x,double y) { return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*pow(x,2)-y*x; } dou…
状态压缩,我们枚举第一行的所有状态,然后根据第一行去转变下面的行,枚举或者深搜直到最后最后一行,可以判断是不是所有的1都可以全部转换为0,记录所有的解,输出最小的一个就可以. 这里有一个很重要的优化,就是当n比m大的,转置这个矩阵,如果不加这个在G++的情况下会超时,C++900Ms多AC.代码及注释如下 #include<stdio.h> #include<iostream> #include<string.h> #include<queue> #incl…
现在,这里有一个功能:  F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=100) 当x在0到100之间时,你能找到最小值吗? 输入 第一行包含一个整数T(1 < = T < = 100),这意味着测试用例的数量.然后T行,每一行只有一个实数Y.(0 < Y < 1e10)当x在0到100之间时,输出值为最小值(精确到小数点后4位). Sample Input 2 100 200 Sample Output -74.4291…