hdoj 2436 Collision Detection

Collision Detection

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1207    Accepted Submission(s): 367

Problem Description
      In physical simulations, video games and computational geometry, collision detection involves algorithms for checking for collision, i.e. intersection, of two given objects. Collision detection algorithms are a basic component of 3D video games. Without them, characters could go through walls and other obstacles.
Here comes an interesting problem, given a ball and a cuboid, you need to detect whether they collide. We say that two objects collide if and only if they share at least one point.

 

Input
      The first line of input is the number of test cases.
Each test case contains two lines, the first line contains 24 integers X1, Y1, Z1, …, X8, Y8, Z8, representing the 8 vertexes of the cuboid. Vertexes are given in random order and you can make sure that all edges of the cuboid are parallel to coordinate axes; the second line contains 4 integers X,Y,Z,R representing the central point of the ball and its radius. All integers given are non-negative and will be less than 100000.

 

Output
      For each case output “Yes” Or “No” on a single line.

 

Sample Input
2
0 0 0 0 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1
2 2 2 2
0 0 0 0 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 1
2 2 2 1

 

Sample Output
Yes
No

 

Source

 

Recommend
lcy   |   We have carefully selected several similar problems for you:  2437 2429 2433 2435 2428
真是日了狗了。。。
读错题wa到死。。。
英文差的原因?
我以为长方体是空心的。。
然后球是有可能在内部
我说我怎么写的那么麻烦,又是判断点,又是判断边,又是判断面。。。。
然后全推了重写。。。
又WA到死。。。
最后发现又是强制转化类型的问题。。。
如果变量是int 类型,即使一出赋值给long long ,在赋值之前的计算也会溢出。。。
所以不溢出的办法就是之前的int 就写成 long long 类型的。。。

作者: CrazyKK

ex-ACMer@hust,stackoverflow-engineer@sensetime

说点什么

您将是第一位评论人!

提醒
wpDiscuz