UVA 10668 - Expanding Rods(数学+二分)】的更多相关文章

UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出公式,设圆弧扇形部弧度r,那么能够计算出铁棒长度为lr/sin(r)这个公式在[0, pi/2]是单调递增的,所以能够用二分法去求解 要注意的一点是最后答案计算过程中带入mid,之前是带入x(二分的左边值),可实际上x是可能等于0的,而带入mid,因为是double型,所以mid实际上表示是一个很趋…
Problem A: Expanding Rods When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on two solid walls and then heated, it expands and takes the…
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1137 题意:有一根绳子的长度为l,在有温度的情况下会变形为一个圆弧,长度为 l1 = (n*c+1)*l;求图中的h;并说明增加的长度不超过原长度的一半: 我们可以二分h,然后根据h求弧长,比较一下和l1的长度即可: 把弧长公式记错我也是醉了:   #include <stdio.h> #include <algorithm> #include <cstring&…
题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: 设弦长为L0(即原长),弧长为L1=(1+n*C)*l0,目标值为h,半径为R,弧所对圆心角为2θ(弧度制).可以得到以下方程组:圆的弧长公式:L1=2θR三角函数公式:L0=2*R*sinθ,变换得θ=arcsin(L0/(2*R))勾股定理:R^2=(R-h)^2+(0.5*L0)^2,变换得…
http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度,答案由①给出.注意,这种写法的精度要求较高. #include<iostream> #include<cmath> #include<cstring> #include<queue> #include<vector> #include<cstd…
题目链接:https://vjudge.net/problem/POJ-1905 题意:有一根长len的木棍,加热了n度,长度会膨胀为len*(1+n*c),c为膨胀系数.现在把这根木棍夹在两堵墙之间,木棍会向上弯曲变成弧形,求弧形中点和原木棍中点的高度差. 思路:刚开始以为是几何题,几何肯定是能做的.然后发现题解是二分,第一次二分double类的变量,学到了.设所求答案为dis,通过dis可以勾骨出半径R,然后求出弧长L,再比较L与真实弧长len.显然dis和L满足二分的单调性,那么就可以做了…
                                                                                                          Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13516   Accepted: 3484 Description When a thin rod of length L is he…
D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on two solid walls and then heated, it expands and takes…
Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion.  Wh…
Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13688   Accepted: 3527 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. Whe…
1137 - Expanding Rods    PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB When a thin rod of length L is heated n degrees, it expands to a new length L' = (1+n*C)*L, where C is the coefficient of heat expansion. When a thi…
                       Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10187   Accepted: 2593 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient…
转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态的杆的中点位置的距离 解题思路: 几何和二分的混合体 如图,蓝色为杆弯曲前,长度为L.红色为杆弯曲后,长度为s.h是所求 依题意知 S=(1+n*C)*L 又从图中得到三条关系式; (1)       角度→弧度公式  θr = 1/2*s (2)       三角函数公式  sinθ= 1/2*L…
Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10287   Accepted: 2615 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is…
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…
Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 17050   Accepted: 4503 Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is…
题目链接:http://poj.org/problem?id=1905 题目大意:原长度为L的线段因受热膨胀为一段弧,线段L.弧长L'.温度n.膨胀率c满足L' =(1+n/c)*L;求线段的中点移动的最小距离. '?'代表的线段就是要求的距离. 怎么办呢?用分治,二分答案,验证弧长是否为目标弧长再进行调整. 首先利用相交弦定理[BA×EA=CA×DA]算出other(AE) 然后用(mid+other)/2得到r(CO) 再用r-mid(AO)除以r(CO)算出cos(θ) 再用acos算出θ…
题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include <stdio.h> #include <math.h> int main() { double l, n, c, r; while(scanf("%lf %lf %lf", &l, &n, &c) != EOF) { && n &l…
/** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include <cstdio> using namespace std; ; int main() { double l,n,c; while(cin>>l>>n>>c){ &&n<&&c<) break; double ll; l…
题目链接: 传送门 Copying Books Time Limit: 3000MS     Memory Limit: 32768 KB Description Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had b…
UVA 题意:两个绿洲之间是沙漠,沙漠的温度不同,告诉起点,终点,求使得从起点到终点的最高温度最小的路径,如果有多条,输出长度最短的路径: 思路:用最小费用(最短路径)最大流(最小温度)也能搞吧,但因为题意是看着博客做的,不小心看到了他的思路,就自己实现了一遍,二分温度,假设当前温度为x,求保证最大温度为x的情况下的最短路:打印路径就是递归打印. #include <iostream> #include <cstdio> #include <cstdlib> #incl…
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4514 题意: 有两个盒子各有n(1≤n≤2e5)个糖,每天随机选一个(概率分别为p,1-p),然后吃一颗糖.直到有一天,打开盒子一看,没糖了!输入n,p,求此时另一个盒子里糖的个数的数学期望. 分析: 根据期望的定义,不妨设最后打开第1个盒子,此时第2个盒子有i颗,则这之前打开过n…
题意: 给定一个素数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)…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1507 比较简单的一题,直接对答案二分.因为对于同一组case,答案m越大,交点的高度就越小,可以从计算交点的函数中看出来.计算交点,假设mx=sqrt(sqr(x)-sqr(m)),my=sqrt(sqr(y)-sqr(m)),这两个是梯子跟两堵墙的交点.那么,交点的高度就是mx*my/(m…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4763 题意:给你一个区间L,R:求区间所有数的并,和或的答案: 思路:两个数的二进制长度不一样,显然是2^(len(r))-1,0: 长度一样取前面相等的部分,或后面填1,且后面填0即可: 跟某场CCPC区间(L,R)取两个数,好像是一样的: #include<bits/s…
http://poj.org/problem?id=1905 题意 :在两堵实心墙中间有一根杆,长度为L,然后给它加热,温度是n,则两墙之间的杆会弯曲,长度会变为L'=(1+n*C)*L,求前后两个状态杆的中心位置的距离 思路 :一部分几何加上最主要的二分 .这个我发现小优姐写的特别好,分析的也很完美,我就不再多解释了,发一下链接吧http://blog.csdn.net/lyy289065406/article/details/6648562 #include<iostream> #incl…
题意: 求正整数L和U之间有多少个整数x满足形如x=pk 这种形式,其中p为素数,k>1 分析: 首先筛出1e6内的素数,枚举每个素数求出1e12内所有满足条件的数,然后排序. 对于L和U,二分查找出小于U和L的最大数的下标,作差即可得到答案. #include <cstdio> #include <cmath> #include <algorithm> typedef long long LL; ; ; ]; ; LL a[maxn], cnt = ; void…
Description In the ``Four Color Map Theorem" was proven with the assistance of a computer. This theorem states that every map can be colored using only four colors, in such a way that no region is colored using the same color as a neighbor region. He…
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…