#include<iostream>
#include<cmath>
using namespace std;
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
typedef struct node
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif)
{
double x,y,z;
double I;
}Node;
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
Node point[101];
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
double distence(Node c,double a,double b)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif)
{
double sum = (c.x - a)*(c.x - a)+(c.y - b)*(c.y - b)+c.z*c.z;//计算光源点到地面点的距离
return sum;
}
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
int main()
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif)
{
int text;
cin>>text;
while(text--)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
int n;
int i,j,k;
cin>>n;
double maxs = 0.0;
for(i =1; i <= n;i++)
cin>>point[i].x>>point[i].y>>point[i].z>>point[i].I;
for(i = -100;i <= 100;i++)//枚举xy平面上从-100到100的xy所有的点,找出最大的
for(j = -100;j <= 100;j++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
double sum = 0.0;
for(k = 1;k <= n;k++)
![](http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
double R;
R = distence(point[k],i,j);
sum += (point[k].I /(R))*(point[k].z/sqrt(R));//计算光强度
}
if(sum > maxs)
maxs = sum;
}
printf("%.2lf\n",maxs);
}
return 0;
}
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)