POJ 1905 Expanding rods (expansion of wood poles) "Mathematical calculation + Binary enumeration"

Source: Internet
Author: User

Expanding rods
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 13516 Accepted: 3484

Description

When a thin rod of length l was heated n degrees, it expands to a new length L ' = (1+n*c) *l, where C was the coefficient of he At expansion.
When a thin rod was mounted on both solid walls and then heated, it expands and takes the shape of a circular segment, the O Riginal 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 Chang E in degrees and the coefficient of heat expansion of the material. Input Data Guarantee This no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should isn't 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 pre Cision.

Sample Input

1000 100 0.000115000 10 0.0000610 0 0.001-1-1-1

Sample Output

61.329225.0200.000

Title: You can understand this, give you a wooden rod, sandwiched between an object. Now the wood rods will swell and swell, and will bend as shown in the extrusion of the objects at both ends.
From a straight wooden rod to a bent wooden rod, what is the height difference between the middle position of the wood rod in both states?

The solution is all in the picture above!

Code:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include < math.h> #include <iostream> #include <string> #include <stack> #include <algorithm> #define EPS 1e-5using namespace Std;int main () {    //L ' = (1+n*c) *l    double L, N, C;    while (scanf ("%lf%lf%lf", &l, &n, &c)!=eof)    {        if (l<0 && n<0 && c<0) break;        double low=0.0;        Double high=0.5*l;        Double mid;        Double s= (1.0+n*c) *l;        Double R;        while (high-low>eps) {            mid= (low+high)/2.0;            R = (4*mid*mid+l*l)/(8*mid);//Simplify the division to reduce the accuracy error            if (2*r*asin (L/(2*r)) < s)                Low=mid;            else                high=mid;        }        printf ("%.3lf\n", mid);    }    return 0;}


POJ 1905 Expanding rods (expansion of wood poles) "Mathematical calculation + Binary enumeration"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.