zoj 2976


题意: 给你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

*/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值