记录编号 |
606724 |
评测结果 |
RRRRRRRRRR |
题目名称 |
4167.镜牢 |
最终得分 |
0 |
用户昵称 |
梦那边的美好AC |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.026 s |
提交时间 |
2025-10-02 15:25:58 |
内存使用 |
3.69 MiB |
显示代码纯文本
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
const double eps = 1e-9;
bool check(double h, double l){
return (h <= eps && h >= -l - eps);
}
bool check3(double x, double y, double z, double a, double b, double c, double& A, double& B, double& C){
double xx = x * x, yy = y * y, zz = z * z, aa = a * a, bb = b * b, cc = c * c;
double tot = 3 * (xx + yy + zz) - (aa + bb + cc);
if(tot < 0) return false;
double g = -sqrt(tot) / 3;
A = (xx - 2 * yy - 2 * zz + aa + 9 * g * g) / (6 * g);
B = (yy - 2 * xx - 2 * zz + bb + 9 * g * g) / (6 * g);
C = (zz - 2 * xx - 2 * yy + cc + 9 * g * g) / (6 * g);
return check(A, x) && check(B, y) && check(C, z) && (xx - A * A >= -eps) && (yy - B * B >= -eps) && (zz - C * C >= -eps);
}
bool checkAD(double x, double y, double z, double a, double b, double c, double& A, double& B, double& C, double& G){
double xx = x * x, yy = y * y, zz = z * z, aa = a * a, bb = b * b, cc = c * c;
double AG = sqrt(2 * bb + 2 * cc - aa) / 3;
A = -x, G = A - AG;
double sum = -3 * AG, diff = (cc - bb) / (3 * AG);
double dB = (sum - diff) / 2, dC = (sum + diff) / 2;
B = dB - x, C = dC - x;
if(!check(B, y) || !check(C, z)) return false;
return (cc - xx - 2 * x * B) <= (yy + eps) && (bb - xx - 2 * x * C) <= (zz + eps);
}
bool checkBD(double x, double y, double z, double a, double b, double c, double& A, double& B, double& C, double& G){
double xx = x * x, yy = y * y, zz = z * z, aa = a * a, bb = b * b, cc = c * c;
double BG = sqrt(2 * aa + 2 * cc - bb) / 3;
B = -y, G = B - BG;
double sum = -3 * BG, diff = (cc - aa) / (3 * BG);
double dA = (sum - diff) / 2, dC = (sum + diff) / 2;
A = dA - y, C = dC - y;
if(!check(A, x) || !check(C, z)) return false;
return (cc - yy - 2 * y * A) <= (xx + eps) && (aa - yy - 2 * y * C) <= (zz + eps);
}
bool checkCD(double x, double y, double z, double a, double b, double c, double& A, double& B, double& C, double& G){
double xx = x * x, yy = y * y, zz = z * z, aa = a * a, bb = b * b, cc = c * c;
double CG = sqrt(2 * aa + 2 * bb - cc) / 3;
C = -z, G = C - CG;
double sum = -3 * CG, diff = (bb - aa) / (3 * CG);
double dA = (sum - diff) / 2, dB = (sum + diff) / 2;
A = dA - z, B = dB - z;
if(!check(A, x) || !check(B, y)) return false;
return (bb - zz - 2 * z * A) <= (xx + eps) && (aa - zz - 2 * z * B) <= (yy + eps);
}
int T;
double x, y, z, a, b, c, A, B, C;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
cin >> T;
while(T --){
cin >> x >> y >> z >> a >> b >> c;
bool flag = false;
if(check3(x, y, z, a, b, c, A, B, C)){
cout << A << ' ' << B << ' ' << C << '\n';
flag = 1;
}
if(!flag){
double bG = 1e18, bA = 0, bB = 0, bC = 0, nG = 0;
if(checkAD(x, y, z, a, b, c, A, B, C, nG) && nG < bG){
bG = nG; bA = A, bB = B, bC = C;
}
if(checkBD(x, y, z, a, b, c, A, B, C, nG) && nG < bG){
bG = nG; bA = A, bB = B, bC = C;
}
if(checkCD(x, y, z, a, b, c, A, B, C, nG) && nG < bG){
bG = nG; bA = A, bB = B, bC = C;
}
cout << bA << ' ' << bB << ' ' << bC << '\n';
}
}
return 0;
}