Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted by 1111 ( 15 years ago )
#include<iostream>
#include<math.h>
using namespace std;
const double pi = acos(-1.0);
double a, b;
double give_square (double alpha, double beta)
{
double gamma = 1.5 * pi - alpha - beta;
double s1 = a * b * sin(alpha) * sin (gamma);
double s2 = a * a * sin(alpha) * cos(alpha) / 2;
double s3 = b * b * sin(gamma) * cos(gamma) / 2;
return s1 + s2 + s3;
}
double give_nice_beta (double alpha)
{
double l = 0;
double r = pi;
for (int i = 0; i < 200; i++)
{
double m1 = l + (r - l) / 3;
double m2 = r - (r - l) / 3;
double s1 = give_square(alpha, m1);
double s2 = give_square (alpha, m2);
if (s1 < s2)
l = m1;
else
r = m2;
}
return l;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
cin >> a >> b;
double l_a = 0, r_a = pi;
for (int i = 0; i < 200; i++)
{
double m1 = l_a + (r_a - l_a) / 3;
double m2 = r_a - (r_a - l_a) / 3;
double m1_b = give_nice_beta (m1);
double m2_b = give_nice_beta (m2);
double s1 = give_square(m1, m1_b);
double s2 = give_square(m2, m2_b);
if (s1 < s2)
l_a = m1;
else
r_a = m2;
}
double bb = give_nice_beta (l_a);
double ans = give_square (l_a, bb);
printf("%lf", ans);
return 0;
}
Revise this Paste
Parent: 40368