Ultraviolet-1356 Bridge

Source: Internet
Author: User

Ultraviolet-1356 Bridge

Description

A suspension bridge suspends the roadway from huge main cables, which extend from one end of the bridge to the other. these cables rest on top of high towers and are secured at each end by anchorages. the towers enable the main cables to be draped over long distances.

Suppose that the maximum distance between two neighboring towers isD, And that the distance from the top of a tower to the roadway isH. Also suppose that the shape of a cable between any two neighboring towers is the same using Ric parabola (as shown in the figure). Now givenB, The length of the bridge andL, The total length of the cables, you are asked to calculate the distance between the roadway and the lowest point of the cable, with minimum number of towers built (Assume that there are always two towers built at the two ends of a bridge ).

Input

Standard input will contain multiple test cases. The first line of the input is a single integerT(1T10) which is the number of test cases.TTest cases follow, each preceded by a single blank line.

For each test case, 4 positive integers are given on a single line.

D-The maximum distance between two neighboring towers; H-The distance from the top of a tower to the roadway; B-The length of the bridge; and L-The total length of the cables.

It is guaranteed thatBL. The cable will always be abve the roadway.

Output

Results shoshould be directed to standard output. Start each case"Case #:"On a single line, where # is the case number starting from 1. Two consecutive cases shocould be separated by a single blank line. No blank line shocould be produced after the last test case.

For each test case, print the distance between the roadway and the lowest point of the cable, as is described in the problem. The value must be accurate up to two decimal places.

Sample Input
220 101 400 40421 2 3 4
Sample Output
Case 1:1. 00 Case 2:1. a: There are several towers on the bridge. The height of the tower is H. The distance between the two adjacent towers does not exceed D. the ropes between the towers form a fully symmetrical parabolic curve, the bridge length is B, and the rope length is L. ask you about the height of the rope at the bottom of the ground y. The number of thought intervals is n = ceil (B/D), the width of each interval is D1 = B/n, and the length of each rope segment is L1 = L/n, then, based on the calculation of the distance from the Ground Based on D1 and L1, We can first find a parabolic curve. When the opening width is w and the height is h, the length of the parabolic curve is solved in two parts, here we need a high-number formula to find the arc length of the function.
#include 
   
    #include 
    
     #include 
     
      #include #include 
      
       using namespace std;double F(double a, double x) {double a2 = a * a, x2 = x * x;return (x * sqrt(a2 + x2) + a2 * log(fabs(x + sqrt(a2 + x2)))) / 2;}double cal_length(double w, double h) {double a = 4.0 * h / (w * w);double b = 1.0 / (2 * a);return (F(b, w/2) - F(b, 0)) * 4 * a;}int main() {int t, cas = 1;scanf("%d", &t);while (t--) {int D, B, H, L;scanf("%d%d%d%d", &D, &H, &B, &L);int n = (B + D - 1) / D;double D1 = (double) B / n;double L1 = (double) L / n;double x = 0, y = H;while (y - x > 1e-5) {double m = x + (y - x) / 2;if (cal_length(D1, m) < L1)x = m;else y = m;}if (cas > 1) printf("\n");printf("Case %d:\n%.2lf\n", cas++, H-x);}return 0;}
      
     
    
   

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.