数学二分——cf700A】的更多相关文章

二分答案 #include<bits/stdc++.h> using namespace std; #define ll long long int n,l,v1,v2,k; double judge(double mid){//在mid时间内走完 ; double t=mid-(v2*mid-l)/(v2-v1);//每人坐车t分钟 double rt=t*(v2-v1)/(v1+v2);//回去的时间 int num=n/k;//送的批数 if(n%k)num++; )*rt; ; ; }…
题意: 给定一个素数p(p <= 1e12),问是否存在一对立方差等于p. 分析: 根据平方差公式: 因为p是一个素数, 所以只能拆分成 1*p, 所以 a-b = 1. 然后代入a = b + 1. 求出 3a² + 3a + 1 = p 化简得a(a+1) = (p-1)/3 令(p-1)/3 = T, 问题化为是否存在整数a使得a(a+1) == T, 那么令 t = (int)sqrt(T),只要判定一下t * (t+1) == T ? 即可 另一种做法是打一个a的表(a只要打到1e6)…
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出公式,设圆弧扇形部弧度r,那么能够计算出铁棒长度为lr/sin(r)这个公式在[0, pi/2]是单调递增的,所以能够用二分法去求解 要注意的一点是最后答案计算过程中带入mid,之前是带入x(二分的左边值),可实际上x是可能等于0的,而带入mid,因为是double型,所以mid实际上表示是一个很趋…
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite ratio…
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to…
DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves partitioning numbers. He wants to know whether it is possible to partition n into the sum of exactly k distinct positive integers. After some thinking he f…
In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero. Formally, given T, CF0, CF1, ..., CFT, then IRR is the solution to the following equation: NPV = CF0 +  +  + K +  = 0 Your task is to find all valid…
D - AtCoder Express Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express. In the plan developed…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5587 题目大意就是初始有一个1,然后每次操作都是先在序列后面添加一个0,然后把原序列添加到0后面,然后从0到末尾,每一个都加上1. 例如:a0, a1, a2 => a0, a1, a2, 1, a0+1, a1+1, a2+1 题解中是这么说的:“ 其实Ai为i二进制中1的个数.每次变化A{k+2^i}=A{k}+1,(k<2^​i​​)不产生进位,二进制1的个数加1.然后数位dp统计前m个数二…
D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走L米,途中可以直接上车,大佬的速度为v1,车的速度为v2,车的位子有限,问大佬们到终点的时间最快是多少. 每个人只能坐一次车. 思路: 这类奥数题真难.有一个比较重要的转化,就是在设定的t时间下,公交车的时间就是全部大佬到终点的时间. 每个人只能坐一次车,所以最后到达终点的人决定总时间,可以看出,用…