QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#55929 | #2839. 3D Geometry | indogent# | AC ✓ | 144ms | 3872kb | C++17 | 3.6kb | 2022-10-15 17:24:04 | 2022-10-15 17:24:06 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef double db;
struct P {
db x, y, z;
}d[4];
const db K = 6.0;
db siz;
double gs(double s, vector<double> g) {
if (s + g[0] >= 100) {
double q = 100 - s;
double ans = q * q * q;
return ans / K / siz;
}
else if (s + g[1] >= 100) {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
return ans / K / siz;
}
else if (s + g[2] >= 100) {
if (s + g[0] + g[1] >= 100) {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
r = q - g[1];
ans -= r * r * r;
return ans / K / siz;
}
else {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
r = q - g[1];
ans -= r * r * r;
r = q - g[0] - g[1];
ans += r * r * r;
return ans / K / siz;
}
}
else {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
r = q - g[1];
ans -= r * r * r;
r = q - g[2];
ans -= r * r * r;
return ans / K / siz;
}
}
void solve() {
for (int i = 1; i < 4; i++) {
scanf("%lf%lf%lf", &d[i].x, &d[i].y, &d[i].z);
d[i].x -= d[0].x;
d[i].y -= d[0].y;
d[i].z -= d[0].z;
}
double fx = 100 / d[1].x;
double fy = 100 / d[1].y;
double fz = 100 / d[1].z;
siz = abs(fx * fy * fz);
for (int i = 2; i < 4; i++) {
d[i].x *= fx;
d[i].y *= fy;
d[i].z *= fz;
}
d[0].x = min(d[2].x, d[3].x);
d[0].y = min(d[2].y, d[3].y);
d[0].z = min(d[2].z, d[3].z);
d[0].x = max(0.0, d[0].x);
d[0].y = max(0.0, d[0].y);
d[0].z = max(0.0, d[0].z);
d[1].x = max(d[2].x, d[3].x) - d[0].x;
d[1].y = max(d[2].y, d[3].y) - d[0].y;
d[1].z = max(d[2].z, d[3].z) - d[0].z;
if (d[1].x < 0 || d[1].y < 0 || d[1].z < 0) {
printf("0\n");
return ;
}
double s = d[0].x + d[0].y + d[0].z;
if (s >= 100) {
printf("0\n");
return ;
}
vector<db> g(3);
g[0] = d[1].x; g[1] = d[1].y; g[2] = d[1].z;
sort(g.begin(), g.end());
/*for (int i = 0; i < 3; i++)
printf("%.6lf!!\n", g[i]);
printf("%.6lf?!!\n", s);*/
if (s + g[0] + g[1] + g[2] <= 100) {
printf("%.9lf\n", g[0] * g[1] * g[2] / siz);
return ;
}
else if (s + g[0] >= 100) {
double q = 100 - s;
double ans = q * q * q;
printf("%.9lf\n", ans / K / siz);
return ;
}
else if (s + g[1] >= 100) {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
printf("%.9lf\n", ans / K / siz);
return ;
}
else if (s + g[2] >= 100) {
if (s + g[0] + g[1] >= 100) {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
r = q - g[1];
ans -= r * r * r;
printf("%.9lf\n", ans / K / siz);
}
else {
double q = 100 - s;
double ans = q * q * q;
double r = q - g[0];
ans -= r * r * r;
r = q - g[1];
ans -= r * r * r;
r = q - g[0] - g[1];
ans += r * r * r;
printf("%.9lf\n", ans / K / siz);
}
return ;
}
else {
double res = 200 - (s + g[0] + g[1] + g[2]);
printf("%.9lf\n", g[0] * g[1] * g[2] / siz - gs(res, g));
}
}
int main() {
while (scanf("%lf%lf%lf", &d[0].x, &d[0].y, &d[0].z) != EOF)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3872kb
input:
0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 2 2 2 0 0 0 1 1 1 0 2 0 2 0 2 1 0 1 0 1 0
output:
0.166666667 0.833333333 0.166666667
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 125ms
memory: 3680kb
input:
-3 -4 2 -5 -5 4 0 0 3 3 4 2 1 5 2 -4 0 0 5 -5 0 -2 -1 3 5 4 2 3 -5 -1 0 -2 -1 -4 -4 -3 -4 4 -2 -2 2 -1 2 2 1 4 0 5 -4 1 0 -5 -2 4 -5 2 -4 5 0 1 2 5 1 -1 0 -3 -1 5 -4 -4 2 -2 2 2 -4 1 3 -1 2 4 2 -2 1 3 2 5 2 -2 -3 -5 -1 0 0 5 4 2 2 5 3 -3 -3 -3 5 4 -4 1 2 -3 2 -4 2 -3 -2 -2 2 -2 -1 -4 -5 3 4 -3 -3 -3...
output:
0 0 0 0 0.708333333 0 0 15.355654762 0 6.562500000 0 0 0 0 0 0.000000000 0 0 0 0 0 1.319444444 0 0.526748971 4.650000000 0 0 0.000000000 1.925925926 0 0 0 0 0.000000000 15.868888889 0.093750000 0 0 0 0 0 0 0 0 0 0 0.259259259 15.000000000 0.000755858 0 1.543209877 0 0 0.258503401 0 0 0 0 0 0.0000000...
result:
ok 100000 numbers
Test #3:
score: 0
Accepted
time: 135ms
memory: 3820kb
input:
-2 -2 -9 1 7 6 -3 -1 -4 -5 -6 2 -3 -4 -9 -10 -5 -4 0 2 -6 7 -9 2 6 4 5 -2 -6 0 8 -8 -3 -3 -10 2 10 -3 -8 -7 -5 -10 -9 -5 1 10 8 -1 7 9 10 6 3 9 -10 -10 -4 0 2 1 -2 4 9 10 5 -4 -6 6 3 7 4 8 6 5 2 3 -7 8 2 3 1 4 -10 7 -7 -3 -6 -10 5 -9 0 3 1 -5 -6 8 5 -3 8 -8 -8 -4 5 -10 4 0 3 1 9 -9 0 -8 8 -3 -7 9 -2...
output:
0 0 0 0 0 16.255732249 0.166666667 0 26.201923077 1.449891068 0 0 0 0 1.280276817 0 0 0 13.431240412 0 0 0 0.045454545 0 18.293333333 0 58.040816327 0.000000000 0 1.736111111 0 0 0 0 144.000000000 43.906250000 0 0.296712803 0 0 0 0 0 0 -0.000000000 33.551038062 43.077942387 0.393750000 7.222222222 0...
result:
ok 100000 numbers
Test #4:
score: 0
Accepted
time: 144ms
memory: 3668kb
input:
91 49 27 -66 89 -21 -22 35 78 -64 41 -19 93 87 -92 72 -32 -67 -48 28 -6 -50 20 78 -33 90 41 75 -51 43 89 9 -89 -35 -73 88 13 13 82 82 -40 72 -21 -75 36 15 79 -66 -21 -99 -49 -33 60 78 -27 -86 -64 61 66 96 -77 37 -71 72 -35 -9 38 86 -68 51 65 15 -16 -64 -25 -72 23 81 -20 60 60 -52 -99 19 24 83 27 -11...
output:
0 0 391.127206881 0 28313.212264151 0 11477.662564207 4368.006677006 14406.483590596 5814.427201071 0 50112.716889796 0 0 0 0 0 0 0 38.151407055 0 0 0 0 0 72.201948734 0 0 0 0 0 0 0 1923.686957716 0 0 3977.938348638 0 0 0 185.220000000 0 0 6771.861224386 0 0 0 2386.263855502 18857.288147055 0 182.04...
result:
ok 100000 numbers
Test #5:
score: 0
Accepted
time: 144ms
memory: 3848kb
input:
-67 241 62 -271 -19 -199 364 487 343 293 433 -343 346 -321 78 -119 68 -487 -319 -45 -165 465 142 491 -310 476 -388 419 409 -124 167 -448 362 233 341 -119 9 -422 290 202 321 -217 310 216 286 172 10 -220 77 107 -282 352 -438 -26 171 81 111 -192 70 -132 376 -361 246 -371 354 -77 -400 -224 457 118 -387 ...
output:
0 417528.646965722 0 0 49064.274495413 5211742.513100329 3370766.246515172 0 0 84.405133541 165311.117708427 0 0 0 52736.152560963 0 132685.480972369 0 1436397.515315553 0 0 0 0 0 7356723.427007439 0 4878653.308295264 0 0 0 0 4575863.995235605 0 0 0 0 0 0 0 0 0 662108.378230372 0 0 0 0 0 13263.21337...
result:
ok 100000 numbers