编程介的小学生 2020-01-16 11:54 采纳率: 20.5%
浏览 104

The Golden Ceiling 的实现的方式

Problem Description
The main office of the Bank of Zork was built in the Aragain Village(later known as Flatheadia)in the year 722 of the Great Underground Empire(GUE). In 788 GUE,the chairman, J.Pierpont Flathead, decided(shortly before his unexplained disappearance in 789), that it was time to completely redesign the already ornate bank atrium with a ceiling covered in brilliant gold leaf.

This new ceiling was not your ordinary ceiling. Although the atrium is essentially a big box,the ceiling would be slanted(supposedly,making the atrium look bigger). At the time,the exact dimensions of the rectangular atrium and the slope and location of the slanted ceiling had not been finalized. Flathead wanted to know how much gold leaf he would have to order from the Frobozz Magic Gold Leaf Company to cover the ceiling for different atrium dimensions and ceiling slants. He also wanted to allow the slanted part to possibly hit the floor of the box and/or the top of the box.

Consider the following rough sketches of some possibly atrium configurations:

Note: The dashed outline represents the original box,the horizontally ruled surface is the slanted part of the ceiling and the cross hatched surface is the part of the top of the box not cut off by the plane. The walls and floor of the atrium are transparent.The total area to be covered(the ceiling)is the slanted part plus any part of the top of the original box that is not cut off by the plane.

Your job is to write a program that Flathead could have used to calculate the amount gold leaf required to cover the ceiling for a particular configuration.
As a sad epilogue,the main branch was brought to ruins when the Curse of Megaboz befell it in 883GUE. Between the barbarian invasions of the 880's and the countless looters that had tread the underground ruins in the year that followed, the entire bank with all its valuables, as well as its very expensive gold leaf ceiling, had been removed or vandalized. More information can be found on-line at:http://www.thezorklibrary.com/history/bank_of_zork.html.

Input
The first line of input contains a single integer P,(1<=P<=1000),which is the number of data sets that follow. Each data set is a single line that contains the data set number,N,followed by a space, followed by seven space separated double precision floating point values,L,W,H,A,B,C and D. The values L,W and H specify the length, width and height of the atrium in Flathead Units(FU's), respectively, and are always positive values. The values A,B,C and D specify the coefficients of the plane equation for the slanted part of the ceiling:

Ax + By + Cz = D

where :0 <= x <= L, 0 <= y <= W, 0 <= z <= H.

One corner of the original box is always at the origin (0,0,0)and the other at (L,W,H). The plane will never be vertical(C will be>=1.0)and the plane will always pass through the interior of the box (there will be points(x,y,z)in the box and strictly above the plane(Ax+By+Cz>D)).and others strictly below the plane (Ax+By+Cz<D).

Output
For each data set there is one line of output. It contains the data set number(N) followed by a single space, followed by an integer value that is the number of square FU's required to cover the ceiling in gold leaf(rounded up to the next square FU).

Sample Input
3

1 10 12 15 -1.3 1 1.1 3.5

2 10 12 10 -1.3 1 1.1 11

3 13 9 10 -1.3 1 1.1 0

Sample Output
1 166
2 164
3 144

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 vmware exsi重置后的密码
    • ¥15 易盾点选的cb参数怎么解啊
    • ¥15 MATLAB运行显示错误,如何解决?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?
    • ¥15 电磁场的matlab仿真
    • ¥15 mars2d在vue3中的引入问题
    • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面