-
-
Save Sd-Invol/811c9e25fd1bf4add93c to your computer and use it in GitHub Desktop.
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 <iostream> | |
#include <cstdio> | |
#include <cstring> | |
#include <cmath> | |
#include <algorithm> | |
#include <stack> | |
#include <queue> | |
#include <string> | |
#include <vector> | |
#include <set> | |
#include <map> | |
#include <cassert> | |
using namespace std; | |
typedef long long LL; | |
#define foreach(it , h) for (typeof((h).begin()) it = (h).begin() ; it != (h).end() ; ++ it) | |
const int N = 505; | |
int r , R; | |
double pi = acos(-1); | |
double F(double A , double B) { | |
return 4 * cos((A + B) / 2) * sin(A / 2) * sin(B / 2); | |
} | |
pair<double , double> cal(double A) { | |
double l = 0 , r = pi - A , m1 , m2; | |
while (r - l > 1e-12) { | |
m1 = (l + l + r) / 3; | |
m2 = (l + r + r) / 3; | |
if (F(A , m1) < F(A , m2)) | |
l = m1; | |
else | |
r = m2; | |
} | |
double B = (l + r) * 0.5; | |
return make_pair(F(A , B) , B); | |
} | |
void work() { | |
if (r + r > R) { | |
puts("NO Solution!"); | |
return; | |
} | |
double p = 1.0 * r / R; | |
double l = 0 , r = pi / 3; | |
while (r - l > 1e-12) { | |
double m = 0.5 * (l + r); | |
if (cal(m).first < p) | |
l = m; | |
else | |
r = m; | |
} | |
double A = (l + r) * 0.5; | |
double B = cal(A).second; | |
double C = pi - A - B; | |
R *= 2; | |
printf("%.15f %.15f %.15f\n" , R * sin(A) , R * sin(B) , R * sin(C)); | |
} | |
int main() { | |
while (~scanf("%d%d" , &r , &R)) | |
work(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment