博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 1905, Expanding Rods
阅读量:6156 次
发布时间:2019-06-21

本文共 1858 字,大约阅读时间需要 6 分钟。

Time Limit: 1000MS  Memory Limit: 30000K

Total Submissions: 4863  Accepted: 1058

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 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.

 

Input

The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. Input data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed.

 

Output

For each line of input, output one line with the displacement of the center of the rod in millimeters with 3 digits of precision.

 

Sample Input

1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1

 

Sample Output

61.329
225.020
0.000

 

Source

Waterloo local 2004.06.12


//
 POJ1905.cpp : Defines the entry point for the console application.
//
#include 
<
iostream
>
#include 
<
cmath
>
#include 
<
algorithm
>
using
 
namespace
 std;
int
 main(
int
 argc, 
char
*
 argv[])
{
    
double
 N,C,L;
    
while
(scanf(
"
%lf%lf%lf
"
,
&
L,
&
N,
&
C)
&&
N
>=
0
&&
C
>=
0
&&
L
>=
0
)
    {
        
if
(N
==
0
||
L
==
0
||
C
==
0
)
        {
            printf(
"
0.000\n
"
);
            
continue
;
        }
        
double
 minv 
=
 
0
,maxv 
=
 acos(
-
1.0
), midv;
        
double
 L2 
=
 ( 
1
 
+
 N 
*
 C ) 
*
 L;
        
while
(maxv 
-
 minv 
>
 1e
-
12
)    
        {
            midv 
=
 (minv 
+
 maxv) 
/
 
2
;
            
if
2
 
*
 L2 
/
 L 
>
 midv 
/
 sin(midv 
/
 
2
))
                minv 
=
 midv;
            
else
                maxv 
=
 midv;
        }
        printf(
"
%.3lf\n
"
,L2 
/
 midv 
*
 (
1
-
cos(midv 
/
 
2
)));
    }
    
return
 
0
;
}

转载于:https://www.cnblogs.com/asuran/archive/2009/10/30/1592697.html

你可能感兴趣的文章
Skip List——跳表,一个高效的索引技术
查看>>
Yii2单元测试初探
查看>>
五、字典
查看>>
前端js之JavaScript
查看>>
Log4J日志配置详解
查看>>
实验7 BindService模拟通信
查看>>
scanf
查看>>
Socket编程注意接收缓冲区大小
查看>>
SpringMVC初写(五)拦截器
查看>>
检测oracle数据库坏块的方法
查看>>
SQL server 安装教程
查看>>
Linux下ftp和ssh详解
查看>>
跨站脚本功攻击,xss,一个简单的例子让你知道什么是xss攻击
查看>>
js时间和时间戳之间如何转换(汇总)
查看>>
js插件---图片懒加载echo.js结合 Amaze UI ScrollSpy 使用
查看>>
java中string和int的相互转换
查看>>
P1666 前缀单词
查看>>
HTML.2文本
查看>>
Ubuntu unity安装Indicator-Multiload
查看>>
解决Eclipse中新建jsp文件ISO8859-1 编码问题
查看>>