Harbin Polytechnic 2015 Summer Training tournament zoj 2976 Light bulbs

Source: Internet
Author: User

 Light BulbsTime  limit:$ MS Memory Limit:65536KB 64bit IO Format:%lld &am P %llu SubmitStatusPracticeZOJ 2976

Description

Wildleopard had fallen in love with the his girlfriend for years. He wanted to end the long match for their love and get married this year. He bought a new house for his family and hired a company to decorate He house. Wildleopard and his fiancee were very satisfied with the postmodern design, except the light bulbs. Varieties of light bulbs were used so, the light in the house differed a lot in different places. Now he asks you, one of the He-best friends, to-help him find out the point of maximum illumination.

To simplify the problem, we can assume each bulb are a point light source and we only need to consider the grid points of T He flat floor of the house. A grid point was a point whose coordinates was both integers. The length and the width of house can be considered infinite. Illumination means the amount of light it go through in one unit area. The illumination of a point can is calculated by simply adding the illumination from each source. The illumination from a source can is calculated by the following equation:

, whereEis the illumination of theIIs the luminous intensity of the source,Ris the distance between the source and the point andIThe is the angle between the normal of the plane and the light to the point.

Given the position and the luminous intensity of the light bulbs, you is asked to find the maximum illumination on the FL Oor at the grid points.

Input

Standard input would contain multiple test cases. The first line of the input was a single integer t (1 <= T <=) which is the number of the test cases . And it'll be followed by T consecutive test cases.

The first line of all test case contains one integer n(1 <= n <=), indicating the number of B ulbs of the lamps in the house. The next n lines would contain 4 integers each, Xi, Yi, Zi, Ii, separated by O NE space, indicating the coordinates and the luminous intensity of the i-th bulb of the lamp. The absolute values of the coordinates do not exceed and Zi are always positive. Ii is a positive integer less than 32768.

Output

Results should is directed to standard output. The output of each test case should being a real number rounded to 0.01, which are the maximum illumination on the floor at th E grid points.

Sample Input

310 0 1 10041 0 1 1000 1 1 100-1 0 1 1000-1 1 10041 0 100 100000 1 100 10000-1 0 100 100000-1 100 10000

Sample Output

100.00147.434.00 this big water problem ah fast after the race 1 a  but what is the use of AH  ~  at that time because of the lack of a condition, he given the scope of the enumeration, then this is good to run ... Simply enumerate  the points in the rectangular region from -100 to 100 and note that when the coordinate system is established, you cannot make the subscript negative, then we can build the origin on (-100,100). Then the triple loop is done.
#include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include < string.h> #include <cctype> #include <string> #include <cmath> #include <vector> #include <stack> #include <queue> #include <map> #include <set>using namespace std;const int inf=102; Double cnt[2*inf+5][2*inf+5];d ouble A (double x) {return x*x;} Double dis (double x1,double y1,double z1,double x2,double y2,double z2) {return sqrt (A (x1-x2) +a (y1-y2) +a (Z1-Z2));}    int main () {int t;cin>>t;        while (t--) {memset (cnt,0,sizeof (CNT));        int n;cin>>n;            for (int i=0;i<n;i++) {double x,y,z,i;scanf ("%lf%lf%lf%lf", &x,&y,&z,&i);                    for (int i=0;i<=2*inf;i++) {for (int j=0;j<=2*inf;j++) {                    Double R=dis (x,y,z,i-inf,j-inf,0);                    Double t=z/r;                cnt[i][j]+= (i/(r*r)) *t;   }         }} double Ans=-1; for (int i=0;i<=2*inf;i++) {for (int j=0;j<=2*inf;j++) {//cout<<cnt[i][j]&              lt;< "";          Ans=max (Cnt[i][j],ans);    }} printf ("%.2lf\n", ans); } return 0;} /*2341-102-102 3*/

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Harbin Polytechnic 2015 Summer Training tournament zoj 2976 Light bulbs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.