QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#421953 | #6763. Triangle Pendant | 36champ | AC ✓ | 4ms | 3924kb | C++20 | 4.2kb | 2024-05-26 12:20:56 | 2024-05-26 12:20:57 |
Judging History
answer
#include <bits/stdc++.h>
#define double long double
#define pb push_back
using namespace std;
double eps = 1e-9;
struct point{
double x, y, z;
point operator+ (point B) {return {x + B.x, y + B.y, z + B.z};}
point operator- (point B) {return {x - B.x, y - B.y, z - B.z};}
point operator* (double d) {return {x * d, y * d, z * d};}
point operator/ (double d) {return {x / d, y / d, z / d};}
};
ostream& operator<<(ostream& os, point p)
{
return os << "("<< p.x << "," << p.y << "," << p.z << ")";
}
double dot(point A, point B)
{
return A.x * B.x + A.y * B.y + A.z * B.z;
}
double norm(point P)
{
return sqrt(dot(P, P));
}
double sq(point A, point B)
{
return dot(A - B, A - B);
}
double dist(point A, point B)
{
return sqrt(sq(A, B));
}
point normalize(point P)
{
return P / norm(P);
}
double angle(point A, point B)
{
return acos(dot(A, B) / norm(A) / norm(B));
}
void cycle(double &a, double &b, double &c)
{
double x = a;
a = b;
b = c;
c = x;
}
void solve()
{
double la, lb, lc, a, b, c;
cin >> la >> lb >> lc >> a >> b >> c;
for(int i=0; i<3; i++)
{
//Hang by C
point A{0, 0, 0}, B{c, 0, 0}, C, D, M;
C = {(c*c+b*b-a*a)/(2*c), 0, 0};
C.y = sqrt(b * b - C.x * C.x);
M = (A + B + C) / 3;
D = C + normalize(C - M) * lc;
if(dist(A, D) < la + eps && dist(B, D) < lb + eps)
{
//cout << "HANG C " << i << "\n";
point X = normalize(M - D);
double ha = - dot(A - D, X);
double hb = - dot(B - D, X);
double hc = - dot(C - D, X);
if(i==0) cout << ha << " " << hb << " " << hc << "\n";
if(i==1) cout << hc << " " << ha << " " << hb << "\n";
if(i==2) cout << hb << " " << hc << " " << ha << "\n";
return;
}
else
{
cycle(a, b, c);
cycle(la, lb, lc);
}
}
for(int i=0; i<3; i++)
{
//Hang by AB
point A{0, 0, 0}, B{c, 0, 0}, C, D;
C = {(c*c+b*b-a*a)/(2*c), 0, 0};
C.y = sqrt(b * b - C.x * C.x);
D = {(c*c+la*la-lb*lb)/(2*c), 0, 0};
D.y = -sqrt(la*la - D.x * D.x);
//cout << A << " " << B << " " << C << " " << D << "\n";
//cout << dist(C, D) << " " << lc << "\n";
point M = (A + B + C) / 3;
double theta = angle(A - D, B - D);
double theta1 = angle(M - D, B - D);
double theta2 = angle(A - D, M - D);
//cout << abs(theta - theta1 - theta2) << "\n";
if(abs(theta - theta1 - theta2) < eps && dist(C, D) < lc + eps)
{
//cout << "HANG AB " << i << "\n";
point X = normalize(M - D);
double ha = - dot(A - D, X);
double hb = - dot(B - D, X);
double hc = - dot(C - D, X);
if(i==0) cout << ha << " " << hb << " " << hc << "\n";
if(i==1) cout << hc << " " << ha << " " << hb << "\n";
if(i==2) cout << hb << " " << hc << " " << ha << "\n";
return;
}
else
{
cycle(a, b, c);
cycle(la, lb, lc);
}
}
//Tetrahedron
point A{0, 0, 0}, B{c, 0, 0}, C, D;
C = {(c*c+b*b-a*a)/(2*c), 0, 0};
C.y = sqrt(b * b - C.x * C.x);
D.x = (c * c + la * la - lb * lb) / (2 * c);
D.y = (dot(C, C) + la*la - lc*lc - 2 * C.x * D.x) / (2 * C.y);
D.z = sqrt(la * la - D.x * D.x - D.y * D.y);
point M = (A + B + C) / 3;
point X = normalize(M - D);
double ha = - dot(A - D, X);
double hb = - dot(B - D, X);
double hc = - dot(C - D, X);
//cout << A << " " << B << " " << C << " " << D << " " << M << "\n";
//cout << A - D << "." << X << " = " << dot(A - D, X) << "\n";
cout << ha << " " << hb << " " << hc << "\n";
}
int main()
{
//ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(12);
int T;
cin >> T;
while(T-->0)
{
solve();
}
}
/*
1
13 5 1000 20 12 12
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
2 1 1 1 1 1 1 2 3 3 1 1 1
output:
-0.816496580928 -0.816496580928 -0.816496580928 -2.000000000000 -2.866025403784 -2.866025403784
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 4ms
memory: 3764kb
input:
1000 21 2 14 12 13 4 29 19 13 15 10 17 29 24 15 29 24 23 29 17 30 18 9 25 27 24 30 16 4 15 28 13 17 12 21 16 16 22 10 22 15 8 15 23 24 23 27 13 26 3 27 15 16 17 5 8 20 17 6 12 24 14 13 15 19 13 27 22 18 18 23 30 22 18 14 11 29 28 7 13 22 22 17 11 19 9 16 22 20 17 21 14 20 6 29 25 20 10 19 9 27 27 17...
output:
-2.935856727587 -2.000000000000 -13.352348999858 -22.146476218003 -16.076204705477 -12.241826659011 -28.027431433360 -18.318582636183 -8.243362186282 -27.266119651334 -13.159319584326 -26.882525397693 -26.534933366926 -22.066632132649 -29.616079568530 -26.967804477492 -12.557669395974 -14.1867221345...
result:
ok 3000 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 3832kb
input:
1000 33 73 79 36 44 48 96 66 45 9 13 14 81 64 9 50 30 26 59 64 65 39 44 13 47 63 7 20 11 27 36 20 52 13 22 20 20 30 29 12 2 12 46 36 41 34 28 39 97 54 70 16 14 5 79 8 97 41 24 18 95 83 59 47 15 50 85 78 67 22 13 17 96 32 70 32 15 18 27 34 76 38 13 29 47 86 95 42 17 34 41 50 50 25 33 22 82 42 81 18 4...
output:
-32.015847290393 -69.684039776768 -75.638061984053 -56.241370959658 -51.194224814505 -45.000000000000 -37.905135499813 -58.350854686242 -9.000000000000 -56.487522082655 -62.826241045256 -58.955695838004 -7.960896812205 -23.730909200749 -7.000000000000 -33.948706405115 -19.875088174858 -30.4828833892...
result:
ok 3000 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 3924kb
input:
1000 171 722 964 22 53 44 379 126 423 98 56 54 233 473 879 86 44 48 159 864 365 39 44 63 847 363 207 70 11 77 736 920 652 13 72 70 318 278 347 44 87 66 691 693 1000 64 50 19 879 8 297 91 74 68 536 888 163 33 44 27 495 83 959 97 65 100 968 643 337 32 61 46 204 797 870 52 62 59 885 978 167 72 63 17 22...
output:
-171.000000000000 -213.850392599167 -223.049554713780 -177.405405405405 -126.000000000000 -222.594594594595 -233.000000000000 -255.050679634078 -243.873475632231 -159.000000000000 -219.738578713327 -199.696129350530 -201.807639006053 -276.325035973243 -207.000000000000 -723.006627426441 -657.1904853...
result:
ok 3000 numbers
Test #5:
score: 0
Accepted
time: 4ms
memory: 3832kb
input:
1000 501 94 77 81 461 510 196 366 645 209 313 464 159 864 365 439 44 463 359 57 440 288 429 255 318 278 347 444 487 466 520 930 929 312 302 162 691 693 1000 564 250 519 33 292 661 856 572 306 410 665 850 503 313 592 947 186 395 292 817 634 466 581 266 563 125 647 672 653 583 469 216 496 554 457 945 ...
output:
-484.158538588081 -22.705846490066 -57.153345139618 -52.426107263072 -307.221896671166 -309.334793607178 -159.000000000000 -620.756001522759 -187.028645031214 -197.471099288721 -57.000000000000 -251.038990245212 -149.368244210289 -117.560921904323 -228.035479087448 -520.000000000000 -617.86452928831...
result:
ok 3000 numbers
Test #6:
score: 0
Accepted
time: 3ms
memory: 3872kb
input:
1000 79 26 423 98 56 54 33 473 79 86 44 48 59 64 365 39 44 63 95 83 959 97 65 100 4 97 870 52 62 59 405 53 8 11 66 75 96 3 407 45 46 67 57 847 5 38 42 72 77 173 16 68 47 53 54 57 945 80 52 83 795 18 100 67 56 72 67 42 748 48 3 50 29 35 566 52 38 18 23 56 116 35 37 15 800 12 62 54 99 74 7 696 95 38 3...
output:
-77.245731657992 -25.995970870233 -122.739840058138 -33.000000000000 -55.050679634078 -43.873475632231 -49.837583792988 -55.920611549364 -80.004560518101 -83.888685265630 -63.594872346937 -138.120730907369 -4.000000000000 -56.988277917716 -60.309480522245 -73.548782106813 -0.148704840194 -8.00000000...
result:
ok 3000 numbers
Test #7:
score: 0
Accepted
time: 3ms
memory: 3868kb
input:
1000 171 722 64 22 53 44 379 26 423 98 56 54 233 473 79 86 44 48 381 864 9 100 80 76 159 64 365 39 44 63 847 63 207 70 11 77 189 410 33 78 87 17 736 920 52 13 72 70 318 278 47 44 87 66 91 693 1000 64 50 19 879 8 297 91 74 68 536 888 63 33 44 27 95 83 959 97 65 100 968 643 37 32 61 46 4 797 870 52 62...
output:
-115.143181363697 -81.047727121232 -64.000000000000 -77.405405405405 -26.000000000000 -122.594594594595 -121.609344453052 -164.296871189504 -79.000000000000 -80.245304603629 -102.144476100647 -9.000000000000 -124.420643288022 -64.000000000000 -98.679304135728 -139.883294367365 -63.000000000000 -132....
result:
ok 3000 numbers