ZOJ2976-Light Bulbs
来源:互联网 发布:ps做淘宝详情页尺寸 编辑:程序博客网 时间:2024/06/03 03:32
Wildleopard had fallen in love with his girlfriend for 20 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 his house. Wildleopard and his fiancee were very satisfied with the postmodern design, except the light bulbs. Varieties of light bulbs were used so that the light in the house differed a lot in different places. Now he asks you, one of his best friends, to help him find out the point of maximum illumination.
To simplify the problem, we can assume each bulb is a point light source and we only need to consider the grid points of the flat floor of the house. A grid point is a point whose coordinates are both integers. The length and the width of house can be considered infinite. Illumination means the amount of light that go through in one unit area. The illumination of a point can be calculated by simply adding the illumination from each source. The illumination from a source can be calculated by the following equation:
Given the position and the luminous intensity of the light bulbs, you are asked to find the maximum illumination on the floor at the grid points.
Input
Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 20) which is the number of test cases. And it will be followed by T consecutive test cases.
The first line of each test case contains one integer n(1 <= n <= 100), indicating the number of bulbs of the lamps in the house. The next n lines will contain 4 integers each, Xi, Yi, Zi, Ii, separated by one 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 100 and Zi is always positive. Ii is a positive integer less than 32768.
Output
Results should be directed to standard output. The output of each test case should be a real number rounded to 0.01, which is the maximum illumination on the floor at the 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
Author: GUAN, Yao
Source: The 5th Zhejiang Provincial Collegiate Programming Contest
题意:告诉你n个光源的光强和光源的坐标,求出坐标中光强最强的整点坐标
解题思路:因为距离光源越远光强必然越弱,并且光源横纵坐标的绝对值不超过100,所有只要在这个范围暴力枚举即可
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;#define LL long longdouble a[300][300];int n;double f(double x1,double y1,double z1,double x2,double y2,double z2 ){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));}int main(){ int t; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); scanf("%d",&n); for(int i=0;i<n;i++) { double x,y,z,I; scanf("%lf%lf%lf%lf",&x,&y,&z,&I); for(int j=0;j<=206;j++) { for(int k=0;k<=206;k++) { double l=f(x,y,z,j-103,k-103,0); a[j][k]+=(I/(l*l))*z/l; } } } double ans=-1; for(int i=0;i<=206;i++) { for(int j=0;j<=206;j++) ans=max(a[i][j],ans); } printf("%.2lf\n",ans); } return 0;}
- ZOJ2976-Light Bulbs
- ZOJ - 2976 Light Bulbs
- BNU16495:Light Bulbs
- ZOJ 2976Light Bulbs
- 【计算几何】ZOJ 2976 Light Bulbs
- Bulbs
- Bulbs
- Bulbs
- Bulbs
- Bulbs
- L - Light Bulbs 解题报告 (隐藏水题)
- 哈理工2015 暑假训练赛 zoj 2976 Light Bulbs
- ZOJ-2976-Light Bulbs【5th浙江省赛】【暴力枚举】
- ZOJ2976暴力法
- hdoj5600N bulbs
- A. Bulbs
- CF615A Bulbs
- Codeforces Bulbs
- 回溯法求八皇后问题
- centos6.4 虚拟机配置host only模式共享主机上网
- opengl图形拾取示例
- 误删除$ORACLE_HOME/dbs下的参数文件、密码文件,如何快速重建
- Linux chmod命令用法
- ZOJ2976-Light Bulbs
- R语言入门(3)时间序列模型的误差分析
- windbg script to set breakpoint on netshell.dll's export function
- javascript中 字符串转JSON 和 JSON遍历,原生超级for()和 jquery的$.each()比较
- 第四次实验 函数调用
- java中值传递与引用传递详解
- 找出一个单向链表的起始位置
- 攻破JAVA NIO技术壁垒
- JSON 与 对象 、集合 之间的转换