### tahsynx's blog

By tahsynx, history, 3 years ago, ,

i'm stuck at problem 1137 at lightoj . My idea is to do binary search over radius of the circle and then calculate the answer. But idk why i'm getting WA. here is my code. Can someone help me, where i'm doing wrong or provide some test case ?

problem description and sample i/o is given bellow:

Problem Statement :

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

3 1000 100 0.0001

150 10 0.00006

10 0 0.001

Case 1: 61.3289915

Case 2: 2.2502024857

Case 3: 0

•
• +3
•

 » 3 years ago, # |   0 Auto comment: topic has been updated by tahsynx (previous revision, new revision, compare).
»
19 months ago, # |
-6

# include <bits/stdc++.h>

using namespace std; main() { long long int t,j=1; cin>>t; while (t--) { double l,te,c; cin>>l>>te>>c; double arc=(1+te*c)*l; double low=0,high=1e9,r=0,ans=0,angle,chord; while (low<high) { r=(low+high)/2; angle=arc/r; chord=2*r*sin(angle/2); if (fabs(chord-l)<=1e-10) { ans=r*(1-cos(angle/2)); break; } else if (chord>l) high=r; else low=r; } //cout<<chord<<endl; cout<<setprecision(12); cout<<"Case "<<j++<<": "<<ans<<endl; } return 0; }

vai amar tay output miltse kintu verdict WA dekhacche

 » 19 months ago, # |   0 #include using namespace std; main() { long long int t,j=1; cin>>t; while (t--) { double l,te,c; cin>>l>>te>>c; double arc=(1+te*c)*l; double low=0,high=1e9,r=0,ans=0,angle,chord; while (lowl) high=r; else low=r; } //cout<
•  » » 19 months ago, # ^ |   0 Tahsin bhai might not notice this :p You may PM him, either via Codeforces or Facebook :)
•  » » » 19 months ago, # ^ |   0 bhai cout dile AC hoyna, printf dile hocche :3
•  » » » 11 months ago, # ^ | ← Rev. 2 →   0 Yamin_7991 vai tui amar code tar precision error ta ektu bol plzYour text to link here...