Problem description:
400 মিটার পরিধি বিশিষ্ট একটি athletic track বানাতে হবে, যার আকৃতি এরকম -
ট্র্যকের ভিতরের আয়তটির দৈর্ঘ্য ও প্রস্থের অনুপাত হতে হবে a:b । তোমাকে a ও b এর মান ইনপুট দেয়া আছে । বলতে হবে, আয়তটির দৈর্ঘ্য ও প্রস্থের মান কত হবে ।
Problem Link
Solution:
মনে করি আয়তটি, ABCD ।
আয়তের প্রস্থের দু পাশে যে দুইটা বৃত্তচাপ আছে, তারা একই বৃত্তের চাপ ।
অতএব, আয়তের কর্ণের দৈর্ঘ্য হবে ঐ বৃত্তের ব্যাস ।
অতএব, AC = sqrt(AD^2 + CD^2)
অতএব, r = OC = OD = AC/2
আমরা জানি, cos A = (b^2 + c^2 - a^2)/2bc
অতএব, cos(theta) = cos COD = (r^2 + r^2 - b^2)/2.r.r
অতএব, s = r.theta
মনে করি, অনুপাতকে x দিয়ে গুণ করলে বাহুর দৈর্ঘ্য পাওয়া যাবে ।
এখন, চাপ = s.x
আয়তের দৈর্ঘ্য = a.x
অতএব, 2.s.x + 2.a.x = 400
অতএব, x = 400 / (2s + 2a)
এখন, আউটপুট হবে a.x এবং b.x
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<math.h> | |
int main() | |
{ | |
int t, cas; | |
double a, b; | |
scanf("%d", &t); | |
for(cas = 1;cas<=t;cas++) | |
{ | |
scanf("%lf : %lf", &a, &b); | |
double r = sqrt(b*b + a*a)/2.0; | |
double theta = acos((r*r + r*r - b*b)/(2.0 * r * r)); | |
double s = r * theta; | |
double x = 400.0/(2.0*a + 2.0*s); | |
printf("Case %d: %.10lf %.10lf\n", cas, x*a, x*b); | |
} | |
return 0; | |
} |
Nicely Described Brother .... hope u should write more regarding LOJ problems
ReplyDeleteHow can You say that both arcs come from same circle?
ReplyDeleteOh..It is written in the main statement...thanks for these useful blogs...
DeleteI'm not understanding how r is sqrt(a*a+b*b) since a & b are not original length and width, these are ratio
ReplyDeleteVery nice
ReplyDeleteI understood the whole thing. But i couldn't understand, why we are multiplying 's' by 'x'?
ReplyDeleteSame problem
DeleteThe would be greater. Why have we take the diagonal as diameter?
ReplyDelete