HDU 2199 (二分法)】的更多相关文章

主要思想就是两端逼近,最后得到结果,0MS #include <iostream> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; ; double deal(double n) { *pow(n,) + *pow(n,) + *pow(n,) + *n + ; } int main() { int t,…
HDU 2199 Can you solve this equation?     Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. InputThe first line of the input contains an integer T(1<=T<=100) which mea…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5999    Accepted Submission(s): 2828 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,…
题意 给Y值,找到多项式 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y 在0到100之间的解. 思路 从0到100,多项式是单调的,故用二分法求解. 代码 double calc(double x){ return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6; } int main(){ int T; cin>>T; while(T--){ double Y; cin>>Y; double L,R; L = 0.0, R= 100.0;…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8595    Accepted Submission(s): 3957 Problem Description Now,given…
http://acm.hdu.edu.cn/howproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13468    Accepted Submission(s): 6006 Problem Description Now,given the…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13475    Accepted Submission(s): 6010 Problem Description Now,given the equation 8*x^4 + 7*x^3…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2199 Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25039    Accepted Submission(s): 10776 Problem Description Now,gi…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6288 题意:给出a,b,k,n可满足(n^a)*(⌈log2n⌉)^b<=k ,求最大的n值三个正整数a,b,k(1≤a,b≤10,10^6≤k≤10^18) 题目思路:这类给数学式子求n的最大值,且数据量大且多的,考虑时间复杂度,我们采用二分法找出n 思路:很明显就是二分n,向上取整可以先预处理出2^62,然后直接循环找到b的底数j,处理n^a*j^b一开始我们用的是powl,但是被卡精度了,卡了…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7493    Accepted Submission(s): 3484 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,…
Can you solve this equation? Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Now,given the equation *x^ + *x^ + *x^ + *x + == Y,can you find its solution between and ; No…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7156    Accepted Submission(s): 3318 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y…
#include<stdio.h> #include<math.h> double f(double x) { return 8*x*x*x*x+7*x*x*x+2*x*x+3*x+6; } int main(void) { int t; double y,x1,x2,x3,y1,y2,y3; scanf("%d",&t); while(t--) { scanf("%lf",&y); x1=0; x2=100; y1=f(x1…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6023    Accepted Submission(s): 2846 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y…
Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. Input The first line of the input contains an integer T(1<=T<=100) which means the number of test…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 27728    Accepted Submission(s): 11717 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 ==…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 22742    Accepted Submission(s): 9865 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 ==…
Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6763    Accepted Submission(s): 3154 Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,…
我们可以发现这个函数是单增的,那么这样二分就好了. 反思:刚转C++,不会用scanf读入实数.(scanf("%lf",&y)) //By BLADEVIL #include <cstdio> #include <iostream> using namespace std; double f(double x) { *x*x*x*x+*x*x*x+*x*x+*x+); } int task,y; int main() { scanf("%d&…
Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. Input The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines fol…
解题思路:给出一个方程 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,求方程的解. 首先判断方程是否有解,因为该函数在实数范围内是连续的,所以只需使y的值满足f(0)<=y<=f(100),就一定能找到该方程的解,否则就无解. 然后是求解过程, 假设一个区间[a,b],mid=(a+b)/2,如果f(a)*f(b)<0,那么函数f(x)在区间[a,b]至少存在一个零点,如果f(a)<0,说明0点在其右侧,那么将a的值更新为当前mid的值,如果f(a)&g…
Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. Input The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. Then T lines fol…
HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsum  贪心 HDU 1004 Let the Balloon Rise  字典树,map HDU 1005 Number Sequence  求数列循环节 HDU 1007 Quoit Design  最近点对 HDU 1008 Elevator  模拟 HDU 1010 Tempter of th…
√√第一部分 基础算法(#10023 除外) 第 1 章 贪心算法 √√#10000 「一本通 1.1 例 1」活动安排 √√#10001 「一本通 1.1 例 2」种树 √√#10002 「一本通 1.1 例 3」喷水装置 √√#10003 「一本通 1.1 例 4」加工生产调度 √√#10004 「一本通 1.1 例 5」智力大冲浪 √√#10005 「一本通 1.1 练习 1」数列极差 √√#10006 「一本通 1.1 练习 2」数列分段 √√#10007 「一本通 1.1 练习 3」线…
http://acm.hdu.edu.cn/showproblem.php?pid=2289 二分法解题. 这个题很恶心...一开始测试样例都不能过,这个π一开始取3.1415926结果是99.999026,改为3.1414927,结果是99.999023..我就发现这个π对结果影响很大,这个题对π的精度要求也比较高...然后我的π就改为3.1415926536... 一开始判断跳出二分的条件是结果差值小于0.000000001,发现超时,改为0.01后还是超时...无语了...然后仔细想想,题…
Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)Total Submission(s): 8506    Accepted Submission(s): 2216 Problem Description Give you three sequences of numbers A, B, C, then we give you a number…
题意: 给出一个序列,对每两个数求异或结果后取最低位的1出来作为一个数,然后求这些数字的和.比如:{a,b,c},结果是lowbit(a^b)+lowbit(a^c)+lowbit(b^a)+lowbit(b^c)+lowbit(c^a)+lowbit(c^b).若不剔除结果为0的,应该有n*n个数的和作为结果. 思路: 试考虑二分法. 观察到可能的取值 lowbit[a]=1,2,4,8.....也就是说最多有29种,结果就是ans=C1*1+C2*2+C3*4+C4*8....C为个数.可以…
题目链接: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=3081 有一段时间没写最大流的题了,这题建图竟然想了好长时间... 刚開始是按着终于的最大流即是做多轮数去想建图,结果根本没思路.后来想了想,能够用二分答案的思想来找终于答案.然后非常明显的并查集,可是并查集学的略渣,竟然卡在并查集上了..= =. 可是也不是并查集的事. .是我建图的思想太正了,略微用点逆向思维并查集就能够非常好利用了. 建图思路是:建立一个源点与汇点,将女孩与源点相连,男孩与汇点…
Problem Description 我们有一个数列A1,A2...An,你现在要求修改数量最少的元素,使得这个数列严格递增.其中无论是修改前还是修改后,每个元素都必须是整数.请输出最少需要修改多少个元素.   Input 第一行输入一个T(1≤T≤10),表示有多少组数据 每一组数据: 第一行输入一个N(1≤N≤105),表示数列的长度 第二行输入N个数A1,A2,...,An. 每一个数列中的元素都是正整数而且不超过106.   Output 对于每组数据,先输出一行 Case #i: 然…