HDU3475
#include
<
stdio.h
>
#include < string .h >
#include < math.h >
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)
struct point {
double x, y, z;
void read() {
scanf("%lf %lf %lf", &x, &y, &z);
}
void out() {
printf("%lf %lf %lf\n", x, y, z);
}
} ;
point unit(point u) {
point ret;
double t = sqrt(u.x*u.x+u.y*u.y+u.z*u.z);
ret.x = u.x / t;
ret.y = u.y / t;
ret.z = u.z / t;
return ret;
}
point xmult(point u, point v) {
point ret;
ret.x = u.y * v.z - v.y * u.z;
ret.y = u.z * v.x - u.x * v.z;
ret.z = u.x * v.y - u.y * v.x;
return ret;
}
double vlen(point p) {
return sqrt(p.x*p.x+p.y*p.y+p.z*p.z);
}
point subt(point u, point v) {
point ret;
ret.x = u.x - v.x;
ret.y = u.y - v.y;
ret.z = u.z - v.z;
return ret;
}
point pvec(point s1, point s2, point s3) {
return xmult(subt(s1, s2), subt(s2, s3));
}
double dmult(point u, point v) {
return u.x * v.x + u.y * v.y + u.z * v.z;
}
int dots_onplane(point a, point b, point c, point d) {
return zero( dmult( pvec(a, b, c), subt(d, a)));
}
int same_side(point p1, point p2, point s1, point s2, point s3) {
return dmult(pvec(s1, s2, s3), subt(p1, s1)) * dmult(pvec(s1, s2, s3), subt(p2, s1)) > eps;
}
int opposite_side(point p1, point p2, point s1, point s2, point s3) {
return dmult(pvec(s1, s2, s3), subt(p1, s1)) * dmult(pvec(s1, s2 ,s3), subt(p2, s1)) < -eps;
}
int intersect_ex(point l1, point l2, point s1, point s2, point s3) {
return opposite_side(l1, l2, s1, s2, s3) && opposite_side(s1, s2, l1, l2, s3) &&
opposite_side(s2, s3, l1, l2, s1) && opposite_side(s3, s1, l1, l2, s2);
}
int dot_inplane_in(point p, point s1, point s2, point s3) {
return zero(vlen(xmult(subt(s1, s2),subt(s1, s3)))-vlen(xmult(subt(p,s1),subt(p,s2)))-
vlen(xmult(subt(p, s2), subt(p, s3)))-vlen(xmult(subt(p,s3), subt(p,s1))));
}
point ini, dic, goal[ 8 ], end, mid;
int main() {
int cases;
scanf("%d", &cases);
for(int t = 1; t <= cases; t ++) {
ini.read();
dic.read();
for(int i = 0; i < 8; i ++)
goal[i].read();
bool flag = false;
if( opposite_side(ini, goal[7], goal[0], goal[1], goal[2]) > 0 ||
dots_onplane(ini, goal[0], goal[1], goal[2]) ) {
end.x = ini.x + dic.x * 10000000;
end.y = ini.y + dic.y * 10000000;
end.z = ini.z + dic.z * 10000000;
mid.x = (goal[0].x + goal[2].x) / 2;
mid.y = (goal[0].y + goal[2].y) / 2;
mid.z = (goal[0].z + goal[2].z) / 2;
point tt, ts;
tt.x = mid.x - ini.x; tt.y = mid.y - ini.y; tt.z = mid.z - ini.z;
tt = unit(tt);
ts = unit(dic);
flag = false;
for(int i = 0; i < 4; i ++) {
if( intersect_ex(ini, end, goal[i], goal[(i+1)%4],goal[(i+2)%4]) ) {
flag = true;
}
}
if( !flag && !dots_onplane(ini, goal[0], goal[1], goal[2]) &&
ts.x == tt.x && ts.y == tt.y && ts.z == tt.z ) flag = true;
if( !flag && opposite_side(ini, end, goal[4], goal[5], goal[6]) ) {
for(int i = 0; i < 4; i ++) {
if( dot_inplane_in(ini, goal[i], goal[(i+1)%4],goal[(i+2)%4]) )
flag = true;
}
}
}
printf("Case %d: ", t);
if(flag) {
puts("Stupid Larrionda!!!");
} else {
puts("Intelligent Larrionda!!!");
}
}
return 0;
}
#include < string .h >
#include < math.h >
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)
struct point {
double x, y, z;
void read() {
scanf("%lf %lf %lf", &x, &y, &z);
}
void out() {
printf("%lf %lf %lf\n", x, y, z);
}
} ;
point unit(point u) {
point ret;
double t = sqrt(u.x*u.x+u.y*u.y+u.z*u.z);
ret.x = u.x / t;
ret.y = u.y / t;
ret.z = u.z / t;
return ret;
}
point xmult(point u, point v) {
point ret;
ret.x = u.y * v.z - v.y * u.z;
ret.y = u.z * v.x - u.x * v.z;
ret.z = u.x * v.y - u.y * v.x;
return ret;
}
double vlen(point p) {
return sqrt(p.x*p.x+p.y*p.y+p.z*p.z);
}
point subt(point u, point v) {
point ret;
ret.x = u.x - v.x;
ret.y = u.y - v.y;
ret.z = u.z - v.z;
return ret;
}
point pvec(point s1, point s2, point s3) {
return xmult(subt(s1, s2), subt(s2, s3));
}
double dmult(point u, point v) {
return u.x * v.x + u.y * v.y + u.z * v.z;
}
int dots_onplane(point a, point b, point c, point d) {
return zero( dmult( pvec(a, b, c), subt(d, a)));
}
int same_side(point p1, point p2, point s1, point s2, point s3) {
return dmult(pvec(s1, s2, s3), subt(p1, s1)) * dmult(pvec(s1, s2, s3), subt(p2, s1)) > eps;
}
int opposite_side(point p1, point p2, point s1, point s2, point s3) {
return dmult(pvec(s1, s2, s3), subt(p1, s1)) * dmult(pvec(s1, s2 ,s3), subt(p2, s1)) < -eps;
}
int intersect_ex(point l1, point l2, point s1, point s2, point s3) {
return opposite_side(l1, l2, s1, s2, s3) && opposite_side(s1, s2, l1, l2, s3) &&
opposite_side(s2, s3, l1, l2, s1) && opposite_side(s3, s1, l1, l2, s2);
}
int dot_inplane_in(point p, point s1, point s2, point s3) {
return zero(vlen(xmult(subt(s1, s2),subt(s1, s3)))-vlen(xmult(subt(p,s1),subt(p,s2)))-
vlen(xmult(subt(p, s2), subt(p, s3)))-vlen(xmult(subt(p,s3), subt(p,s1))));
}
point ini, dic, goal[ 8 ], end, mid;
int main() {
int cases;
scanf("%d", &cases);
for(int t = 1; t <= cases; t ++) {
ini.read();
dic.read();
for(int i = 0; i < 8; i ++)
goal[i].read();
bool flag = false;
if( opposite_side(ini, goal[7], goal[0], goal[1], goal[2]) > 0 ||
dots_onplane(ini, goal[0], goal[1], goal[2]) ) {
end.x = ini.x + dic.x * 10000000;
end.y = ini.y + dic.y * 10000000;
end.z = ini.z + dic.z * 10000000;
mid.x = (goal[0].x + goal[2].x) / 2;
mid.y = (goal[0].y + goal[2].y) / 2;
mid.z = (goal[0].z + goal[2].z) / 2;
point tt, ts;
tt.x = mid.x - ini.x; tt.y = mid.y - ini.y; tt.z = mid.z - ini.z;
tt = unit(tt);
ts = unit(dic);
flag = false;
for(int i = 0; i < 4; i ++) {
if( intersect_ex(ini, end, goal[i], goal[(i+1)%4],goal[(i+2)%4]) ) {
flag = true;
}
}
if( !flag && !dots_onplane(ini, goal[0], goal[1], goal[2]) &&
ts.x == tt.x && ts.y == tt.y && ts.z == tt.z ) flag = true;
if( !flag && opposite_side(ini, end, goal[4], goal[5], goal[6]) ) {
for(int i = 0; i < 4; i ++) {
if( dot_inplane_in(ini, goal[i], goal[(i+1)%4],goal[(i+2)%4]) )
flag = true;
}
}
}
printf("Case %d: ", t);
if(flag) {
puts("Stupid Larrionda!!!");
} else {
puts("Intelligent Larrionda!!!");
}
}
return 0;
}