专题一 POJ-1905

题目
When a thin rod of length L is heated n degrees, it expands to a new length L’=(1+nC)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 shape of a circular segment, the original rod being the chord of the segment.
Your task is to compute the distance by which the center of the rod is displaced.
题目大意
红线为L’,蓝线为L,求h
解题思路
算!
设半径为R
θ=arcsin(L/2R)
L’=2θ/(2π) * 2πR=2Rθ
L=2sqrt((R * R) -(R-h) * (R-h))
整理上式子得
L’=2Rarcsin(L/2R) ①
R=(L * L+4h
h)/(8h) ②
将②带①
s= L’=(4
hh+LL)/4.0/hasin(4hL/(4h*+L*L))
s对h求导得到s’在h>=0时是单调增加的
所以可以用二分法求h
代码实现

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
const double esp=1e-5;
int main()
{
	while (true)
	{
		double L,n,c,ans=0,s;
		cin>>L>>n>>c;
		if (L<0) break;
		s=(1+n*c)*L;
        double l=0.0,r=L;
		while (l+esp<=r)
		{
			double mid=(l+r)/2;
			double R=(4*mid*mid+L*L)/(8*mid);
			double a=2*R*asin(L/(2*R));
			if (a<=s) l=mid;
		    else r=mid;
		    ans=mid;
		}
		printf("%.3f\n",ans);
	}
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值