BNU16495:Light Bulbs
来源:互联网 发布:mac pro type c 编辑:程序博客网 时间:2024/05/22 03:26
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 integerT (1 <= T <= 20) which is the number of test cases. And it will be followed byT 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 nextn lines will contain 4 integers each, Xi, Yi,Zi, Ii, separated by one space, indicating the coordinates and the luminous intensity of thei-th bulb of the lamp. The absolute values of the coordinates do not exceed 100 andZi 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
题意:一开始还以为是什么高深的数学题,毕竟看到几何图了- -,然后题意又坑了半天,一直纠结z是啥,后来才发现灯泡原来是三维坐标,汗~然后看清楚题意了其实很简单,就是套用公式求出房间最亮的那个点的亮度
思路:由于房间水平坐标的x,y绝对值在100以内,所以直接枚举套用公式即可
#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>using namespace std;struct node{ double x,y,z,l;}a[105];int n;double solve(double x,double y){ double r,bi; double ans = 0; int i; for(i = 0;i<n;i++) { r = sqrt(a[i].z*a[i].z+(a[i].x-x)*(a[i].x-x)+(a[i].y-y)*(a[i].y-y));//半径 bi = a[i].z/r;//cos的值 ans+=a[i].l*bi/r/r;//公式 } return ans;}int main(){ int t,i,j; double maxn,k; scanf("%d",&t); while(t--) { scanf("%d",&n); maxn = 0; for(i = 0;i<n;i++) scanf("%lf%lf%lf%lf",&a[i].x,&a[i].y,&a[i].z,&a[i].l); for(i = -100;i<=100;i++) { for(j = -100;j<=100;j++)//枚举 { k = solve(i,j); maxn = max(maxn,k); } } printf("%.2f\n",maxn); } return 0;}
- BNU16495:Light Bulbs
- ZOJ - 2976 Light Bulbs
- ZOJ 2976Light Bulbs
- ZOJ2976-Light Bulbs
- 【计算几何】ZOJ 2976 Light Bulbs
- Bulbs
- Bulbs
- Bulbs
- Bulbs
- Bulbs
- L - Light Bulbs 解题报告 (隐藏水题)
- 哈理工2015 暑假训练赛 zoj 2976 Light Bulbs
- ZOJ-2976-Light Bulbs【5th浙江省赛】【暴力枚举】
- hdoj5600N bulbs
- A. Bulbs
- CF615A Bulbs
- Codeforces Bulbs
- H - Bulbs
- cx_Oracle - ImportError: DLL load failed: The specific module could not be found
- oracle using 和on的用法不同处
- 在Eclipse安装Aptana插件
- JavaIO之ByteArrayStream(一)
- [CF 219D]Choosing Capital for Treeland[树形DP]
- BNU16495:Light Bulbs
- 编程之美:二进制中的1
- Linux内核设计艺术笔记(一)
- 弯曲的手指
- JavaIO之Stream
- 线性的时间内选择出rank n的元素
- 数据结构中的表达式求值
- tnsの設定
- JavaIO之管道(二)