Problem B. GSS and Interesting Sculpture

Problem B. 

GSS and Interesting SculptureInput file: standard inputOutput file: standard outputTime limit: 1 secondsMemory limit: 512 mebibytesGSS is painting an strange sculpture, the sculpture contests of two balls and they may intersect. Your task is tocalculate the area of the surface of the sculpture.InputInput contains multiple cases, please process to the end of input.For each line, there are three integers, R, r, L, R and r the radius of the two balls, L is the distance of the centerof two balls.0 < R, r, L ≤ 100, |R − r| < L ≤ |R + r|OutputFor each input, output one line with the answer, the area of the surface of the sculpture. Let the standard answerbe a, and your answer be b, your answer will be considered as correct if and only if |a−b|max(a,1) < 10−6.Examples

standard input                   standard output

         3 4 5                          271.433605270158

         3 3 3                          169.646003293849

         1 2 3                           62.831853071796

题意:有两个球的半径 ,和圆心距 为 r,R,l ;球可以重叠成一个形状,求这个物体的表面积。



#define maxn 805
const double pi=3.141592653589793238;
typedef long long ll;
using namespace std;
int main()
    double r,R,l;
        double x=(r*r+l*l-R*R)/(2.0*l);
        double h1=r-x;
        double h2=R-(l-x);
        double s1=4*pi*r*r;
        double s2=4*pi*R*R;
        double s=s1+s2;
        double ss1=2*pi*r*h1;
        double ss2=2*pi*R*h2;
          double s1=4*pi*r*r;
          double s2=4*pi*R*R;

Interesting Housing Problem


Problem DescriptionnFor any school, it is hard to find a feasible accommodation plan with every student assigned to a suitable apartment while keeping everyone happy, let alone an optimal one. Recently the president of University ABC, Peterson, is facing a similar problem. While Peterson does not like the idea of delegating the task directly to the class advisors as so many other schools are doing, he still wants to design a creative plan such that no student is assigned to a room he/she dislikes, and the overall quality of the plan should be maximized. Nevertheless, Peterson does not know how this task could be accomplished, so he asks you to solve this so-called "interesting" problem for him.nSuppose that there are N students and M rooms. Each student is asked to rate some rooms (not necessarily all M rooms) by stating how he/she likes the room. The rating can be represented as an integer, positive value meaning that the student consider the room to be of good quality, zero indicating neutral, or negative implying that the student does not like living in the room. Note that you can never assign a student to a room which he/she has not rated, as the absence of rating indicates that the student cannot live in the room for other reasons.nWith limited information available, you've decided to simply find an assignment such that every student is assigned to a room he/she has rated, no two students are assigned to the same room, and the sum of rating is maximized while satisfying Peterson's requirement. The question is … what exactly is the answer?n nnInputnThere are multiple test cases in the input file. Each test case begins with three integers, N, M, and E (1 <= N <= 500, 0 <= M <= 500, 0 <= E <= min(N * M, 50000)), followed by E lines, each line containing three numbers, Si, Ri, Vi, (0 <= Si < N, 0 <= Ri < M, |Vi| <= 10000), describing the rating Vi given by student Si for room Ri. It is guaranteed that each student will rate each room at most once.nEach case is followed by one blank line. Input ends with End-of-File.n nnOutputnFor each test case, please output one integer, the requested value, on a single line, or -1 if no solution could be found. Use the format as indicated in the sample output.n nnSample Inputn3 5 5n0 1 5n0 2 7n1 1 6n1 2 3n2 4 5nn1 1 1n0 0 0nn1 1 0n nnSample OutputnCase 1: 18nCase 2: 0nCase 3: -1n



Problem DescriptionnnnnImagine a box, made of copper plate. Imagine a second one, intersecting the first one, and several others, intersecting each other (or not). That is how the sculptor Oto Boxing constructs his sculptures. In fact he does not construct that much, he only makes the design; the actual construction is contracted out to a construction company. For the calculation of the costs of construction the company needs to know the total area of copper plate involved. Parts of a box that are hidden in another box are not realized in copper, of course. (Copper is quite expensive, and prices are rising.) After construction, the total construction is plunged into a bath of chemicals. To prevent this bath from running over, the construction company wants to know the total volume of the construction. Given that a construction is a collection of boxes, you are asked to calculate the area and the volume of the construction.nnSome of Oto's designs are connected, others are not. Either way, we want to know the total area and the total volume. It might happen that the boxes completely enclose space that is not included in any of the boxes (see the second example below). Because the liquid cannot enter that space, its volume must be added to the total volume. Copper plate bordering this space is superfluous, of course, so it does not add to the area.n nnInputnOn the first line one positive number: the number of testcases, at most 100. After that per testcase:nn* One line with an integer n (1 ≤ n ≤ 50): the number of boxes involved.n* n lines with six positive integers x0, y0, z0, x, y, z (1 ≤ x0, y0, z0, x, y, z ≤ 500): the triple (x0, y0, z0) is the vertex of the box with the minimum values for the coordinates and the numbers x, y, z are the dimensions of the box (x, y and z dimension, respectively). All dimensions are in centimeters. The sides of the boxes are always parallel to the coordinate axes.n nnOutputnPer testcase:nn* One line with two numbers separated by single spaces: the total amount of copper plate needed (in cm2), and the total volume (in cm3).n nnSample Inputn2n2n1 2 3 3 4 5n6 2 3 3 4 5n7n1 1 1 5 5 1n1 1 10 5 5 1n1 1 2 1 4 8n2 1 2 4 1 8n5 2 2 1 4 8n1 5 2 4 1 8n3 3 4 1 1 1n nnSample Outputn188 120n250 250n


  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他