首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【LightOJ】1137 - Expanding Rods(二分 & 几何)

【LightOJ】1137 - Expanding Rods(二分 & 几何)

作者头像
FishWang
发布2025-08-27 09:10:00
发布2025-08-27 09:10:00
13700
代码可运行
举报
运行总次数:0
代码可运行

点击打开题目

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 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. That means you have to calculate h as in the picture.

Input

Input starts with an integer T (≤ 20), denoting the number of test cases.

Each case contains three non-negative real numbers: the initial length of the rod in millimeters L, the temperature change in degrees n and the coefficient of heat expansion of the material C. Input data guarantee that no rod expands by more than one half of its original length. All the numbers will be between 0 and 1000 and there can be at most 5 digits after the decimal point.

Output

For each case, print the case number and the displacement of the center of the rod in single line. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

3 1000 100 0.0001 150 10 0.00006 10 0 0.001

Case 1: 61.3289915 Case 2: 2.2502024857 Case 3: 0

主要是几何分析,这里我就不一点点画图了,给一个链接,分析的就很好:点击打开链接

代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#include <cstdio>
#include <cmath>
int main()
{
	double left,right,mid;
	double l,n,s,c;
	double r;
	int Case = 1;
	int u;
	scanf ("%d",&u);
	while (u--)
	{
		scanf ("%lf %lf %lf",&l,&n,&c);
		printf ("Case %d: ",Case++);
		s = (1.0+n*c)*l;
		left = 0;
		right = l / 2.0;
		while (right - left > 1e-8)
		{
			mid = (right + left) / 2.0;
			r = (l*l + 4*mid*mid) / (8*mid);
			double t = asin(l/2/r);
			if (t * r * 2.0 < s)
				left = mid;
			else
				right = mid;
		}
		printf ("%.6lf\n",left);
	}
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2025-08-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Input
  • Output
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档