Light BulbsTime Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu

Description
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: , where E is the illumination of the point, I is the luminous intensity of the source, R is the distance between the source and the point and i is the angle between the normal of the plane and the light to the point. 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
3
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

Sample Output

100.00
147.43
4.00 这个大水题啊 赛后迅速1 a 只是有啥用啊 ~ 当时由于少看了一个条件。他给定了枚举范围 ,那么这就好办了…… 仅仅需枚举-100 到100 矩形区域内的点就可以
另外注意坐标系建立的时候不能使下标为负。那么我们就能够把原点建在(-100。100)上。然后三重循环搞定。
 
#include<iostream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<string.h>
#include<cctype>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int INF=102;
double cnt[2*INF+5][2*INF+5]; double A(double x)
{
return x*x;
}
double dis(double x1,double y1,double z1,double x2,double y2,double z2 )
{ return sqrt(A(x1-x2)+A(y1-y2)+A(z1-z2));
}
int main()
{
int t;cin>>t;
while(t--)
{
memset(cnt,0,sizeof(cnt));
int n;cin>>n;
for(int i=0;i<n;i++)
{
double x,y,z,I;scanf("%lf%lf%lf%lf",&x,&y,&z,&I);
for(int i=0;i<=2*INF;i++)
{
for(int j=0;j<=2*INF;j++)
{ double R=dis(x,y,z,i-INF,j-INF,0);
double t=z/R;
cnt[i][j]+=(I/(R*R))*t;
} }
}
double ans=-1;
for(int i=0;i<=2*INF;i++)
{
for(int j=0;j<=2*INF;j++)
{
//cout<<cnt[i][j]<<" ";
ans=max(cnt[i][j],ans);
} }
printf("%.2lf\n",ans);
}
return 0;
}
/*
234
1
-102 -102 3
*/

哈理工2015 暑假训练赛 zoj 2976 Light Bulbs的更多相关文章

  1. 哈理工2015暑假训练赛 zoj 2078Phone Cell

    Phone CellTime Limit:10000MS    Memory Limit:32768KB    64bit IO Format:%lld & %llu SubmitStatus ...

  2. zoj 2976 Light Bulbs(暴力枚举)

    Light Bulbs Time Limit: 2 Seconds      Memory Limit: 65536 KB Wildleopard had fallen in love with hi ...

  3. 哈理工2015暑假集训 zoj 2975 Kinds of Fuwas

    G - Kinds of Fuwas Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu Subm ...

  4. 浙江理工2015.12校赛-A

    孙壕请一盘青岛大虾呗 Time Limit: 5 Sec Memory Limit: 128 MB Submit: 577 Solved: 244 Description 话说那一年zstu与gdut ...

  5. 浙江理工2015.12校赛-F Landlocked

    Landlocked Time Limit: 5 Sec Memory Limit: 128 MB Submit: 288 Solved: 39 Description Canada is not a ...

  6. 浙江理工2015.12校赛-G Jug Hard

    Jug Hard Time Limit: 10 Sec Memory Limit: 128 MB Submit: 1172 Solved: 180 Description You have two e ...

  7. 浙江理工2015.12校赛-B 七龙珠

    七龙珠 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 781 Solved: 329 Description 话说孙壕请吃了青岛大虾后,一下子变穷了,就 ...

  8. 2015暑假训练(UVALive 5983 - 5992)线段树离线处理+dp

    A: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83690#problem/A 题意:N*M的格子,从左上走到右下,要求在每个点的权值 ...

  9. [置顶] 2013_CSUST暑假训练总结

    2013-7-19 shu 新生训练赛:母函数[转换成了背包做的] shuacm 题目:http://acm.hdu.edu.cn/diy/contest_show.php?cid=20083总结:h ...

随机推荐

  1. C++代码学习之一:组合模式例子

    #include"AbstractFile.h" void AbstractFile::add(AbstractFile*) { } void AbstractFile::remo ...

  2. PAT Basic 1022

    1022 D进制的A+B 输入两个非负10进制整数A和B(<=2^30^-1),输出A+B的D (1 < D <= 10)进制数. 输入格式: 输入在一行中依次给出3个整数A.B和D ...

  3. linux python 安装 pip出现 No module named 'setuptools'

    1.下载pip wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#m ...

  4. 利用visual studio 搜索替换功能清除项目中javascript文件的debugger;

    在做web项目中,写js代码时候,会有一堆的debugger;,当时又懒得删,后面就多起来了,在vs的编辑器里面,其查找替换功能支持正则和整个项目/解决方案替换,这样就很容易删掉debugger;,方 ...

  5. python 三——列表、字典、元祖、字符串、set

    本节内容 1.列表 2.元祖 3.字典 4.字符串 不可变类型:整型.字符串.元组tuple 可变类型:列表list.字典dict 1.列表 >>> names ['Alex', ' ...

  6. Java-在一个包装器对象中包装一个原始类型

    使用基本类型的包装对象,好处可以为空且可以序列化 package com.tj; public class MyClass2 { public static void main(String[] ar ...

  7. unittest跳过测试和预期失败

    在运行测试时,有时需要直接跳过某些测试用例,或者当用例符合某个条件时跳过测试,又或者直接将测试用例设置为失败.unittest提供了这些需求的装饰器. unittest.skip(reason) 无条 ...

  8. 九度oj 题目1208:10进制 VS 2进制

    题目描述: 对于一个十进制数A,将A转换为二进制数,然后按位逆序排列,再转换为十进制数B,我们乘B为A的二进制逆序数.    例如对于十进制数173,它的二进制形式为10101101,逆序排列得到10 ...

  9. 性能学习笔记之四--事务,思考时间,检查点,集合点和手写lr接口

    一.事物,思考时间,检查点,集合点 1.事务 lr里面的事物是lr运行脚本的基础.lr里面 要测试的三个维度都以事物为单位,所以一定要有事物.事务的概念贯穿loadrunner的使用,比如我们说的响应 ...

  10. 【Luogu】P2340奶牛会展

    题目链接 突发奇想可以用f[i]表示智商和为i的时候情商最大是多少.这样就变成了一个背包问题. 最后更新答案的时候从0到最大背包容量遍历,最后答案是最大的i+f[i]; 但是虽然答案只能从0到m里选, ...