题意: 给你n盏灯的三维坐标(x,y,z),问在房间里哪个点的光照最强,
因为这个点落在房间的地板上(z=0),且x,y的范围在-100~100内,所以
枚举每个点,利用所给的公式求出这个点的光照强度,得出最强的光照就可以了。。。。
#include<cstdio>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<map>
#include<cmath>
#include<iostream>
#include <queue>
#include <stack>
#include<algorithm>
#include<set>
using namespace std;
#define INF 1e8
#define inf -0x3f3f3f3f
#define eps 1e-8
#define LL long long
#define max 10
#define mol 100000007
struct point
{
double x,y,z,i;
}p[110];
int main()
{
int t,k;
int i,j;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z,&p[i].i);
double maxn=0,ans;
for(i=-100;i<=100;i++)
{
for(j=-100;j<=100;j++)
{
ans=0;
for(k=0;k<n;k++)
{
double temp=(p[k].x-i)*(p[k].x-i)+(p[k].y-j)*(p[k].y-j)+p[k].z*p[k].z;
double cnt=p[k].i*p[k].z;
ans+=cnt/(temp*sqrt(temp));
if(ans>maxn)
{
maxn=ans;
}
}
}
}
printf("%.2lf\n",maxn);
}
return 0;
}
/*
99
1
0 0 1 100
4
1 0 1 100
0 1 1 100
-1 0 1 100
0 -1 1 100
4
1 0 100 10000
0 1 100 10000
-1 0 100 10000
0 -1 100 10000
*/