Pagini recente » Cod sursa (job #2215375) | Cod sursa (job #1936669) | Cod sursa (job #1806592) | Cod sursa (job #451579) | Cod sursa (job #1340979)
#include <cmath>
#include <iostream>
using namespace std;
const long double eps = 1.e-9;
const long double pi = 3.14159265;
long double L[3], U[3];
void solve(int nrl, int nru) {
if(nru == 2) {
++nru;
for(int i = 0; i < 3; ++i) {
if(fabs(U[i] + 1) <= eps)
U[i] = pi - U[(i + 1) % 3] - U[(i + 2) % 3];
if(U[i] < eps || U[i] > pi - eps) {
cout << "Invalid input." << '\n';
return;
}
}
}
if(nrl == 3) {
long double s = 0;
for(int i = 0; i < 3; ++i) {
if(fabs(U[i] + 1) <= eps)
U[i] = acos((L[(i + 1) % 3] * L[(i + 1) % 3] + L[(i + 2) % 3] * L[(i + 2) % 3] - L[i] * L[i])/ (2 * L[(i + 1) % 3] * L[(i + 2) % 3]));
s += U[i];
if(U[i] < eps || U[i] > pi - eps || L[i] < eps) {
cout << "Invalid input." << '\n';
return;
}
}
if(fabs(s - pi) > eps) {
cout << "Invalid input." << '\n';
return;
}
for(int i = 0; i < 3; ++i)
cout << L[i] << ' ' << U[i] << ' ';
}
else if(nrl == 2) {
if(nru == 3) {
__
}
}
else if(nr1 == 1) {
__
}
else {
cout << "More than one solution.";
}
}
int main()
{
int T;
cin >> T;
for(int t = 1; t <= T; ++t) {
int nru = 3, nrl = 3;
for(int i = 0; i < 3; ++i) {
cin >> L[i] >> U[i];
if(fabs(L[i] + 1) <= eps)
--nrl;
if(fabs(U[i] + 1) <= eps)
--nru;
}
solve(nrl, nru);
}
return 0;
}