zoj 2976 Light Bulbs(暴力枚举)
Light Bulbs
Time Limit: 2 Seconds Memory Limit: 65536 KB
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
Author: GUAN, Yao
Source: The 5th Zhejiang Provincial Collegiate Programming Contest
//本来以为是函数超时,结果是因为多组数据的读入而超时的
#include <iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int t,n;
int x[],y[],z[],l[];
double ans;
int main()
{
scanf("%d",&t);
for(;t>;t--)
{
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d%d%d%d",&x[i],&y[i],&z[i],&l[i]);
ans=;
for(int i=-;i<=;i++)//数据小,可以纯暴力
for(int j=-;j<=;j++)
{
double sum=;
for(int k=;k<=n;k++)
{
//double R=sqrt((x[k]-i)*(x[k]-i)+(y[k]-j)*(y[k]-j)+z[k]*z[k]);
double R=sqrt(pow(x[k]-i,)+pow(y[k]-j,)+z[k]*z[k]);
//if (i==0 && j==0) printf("%lf\n",(double)R);
sum=sum+l[k]/(R*R*R)*z[k];
}
//ans=ans<sum?sum:ans;
ans=max(ans,sum);
//本来以为是因为用了数学函数所以超时原来是以为多组数据的问题,去掉whil(~scanf("%d",&t))就ac了
}
printf("%.2lf\n",ans);
} return ;
}
zoj 2976 Light Bulbs(暴力枚举)的更多相关文章
- 哈理工2015 暑假训练赛 zoj 2976 Light Bulbs
MS Memory Limit:65536KB 64bit IO Format:%lld & %llu SubmitStatusid=14946">Practice ...
- [ACM] ZOJ 3816 Generalized Palindromic Number (DFS,暴力枚举)
Generalized Palindromic Number Time Limit: 2 Seconds Memory Limit: 65536 KB A number that will ...
- HDU 4770 Lights Against Dudely 暴力枚举+dfs
又一发吐血ac,,,再次明白了用函数(代码重用)和思路清晰的重要性. 11779687 2014-10-02 20:57:53 Accepted 4770 0MS 496K 2976 B G++ cz ...
- Codeforces Round #325 (Div. 2) B. Laurenty and Shop 有规律的图 暴力枚举
B. Laurenty and Shoptime limit per test1 secondmemory limit per test256 megabytesinputstandard input ...
- CodeForces 742B Arpa’s obvious problem and Mehrdad’s terrible solution (暴力枚举)
题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000 ...
- 2014牡丹江网络赛ZOJPretty Poem(暴力枚举)
/* 将给定的一个字符串分解成ABABA 或者 ABABCAB的形式! 思路:暴力枚举A, B, C串! */ 1 #include<iostream> #include<cstri ...
- HNU 12886 Cracking the Safe(暴力枚举)
题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12886&courseid=274 解题报告:输入4个数 ...
- 51nod 1116 K进制下的大数 (暴力枚举)
题目链接 题意:中文题. 题解:暴力枚举. #include <iostream> #include <cstring> using namespace std; ; ; ch ...
- Codeforces Round #349 (Div. 1) B. World Tour 最短路+暴力枚举
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一 ...
随机推荐
- Spring-1-H Number Sequence(HDU 5014)解题报告及测试数据
Number Sequence Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Pro ...
- python3.5实现购物车
一.购物车实现: 购物车功能: 用户登录:密码错误三次锁定账户. 商品列表分页显示:输入页码查看指定页数商品信息. 已购买商品列表:显示已购买的物品列表:可以模糊查询已购买的商品并在终端打印. 充值: ...
- 如何在idea中设置 jsp 内容修改以后,立即生效而不用重新启动服务?
点击 run---->edit configuration--->
- C++通过HTTP请求Get或Post方式请求Json数据(转)
原文网址:https://www.cnblogs.com/shike8080/articles/6549339.html #pragma once#include <iostream>#i ...
- C++在VS下创建、调用dll
转自:http://www.cnblogs.com/houkai/archive/2013/06/05/3119513.html 目录 1.dll的优点 代码复用是提高软件开发效率的重要途径.一般而言 ...
- 前端js实现字符串/图片/excel文件下载
在web开发中,如果你想让用户下载或者导出一个文件,应该怎么做呢?传统的做法是在后端存储或者即时生成一个文件来提供下载功能,这样的优势是可以做权限控制.数据二次处理,但缺点是需要额外发起请求.增大服务 ...
- cordova linux 安装并编出第一个demo-android
cordova可以做到一次编写到处运行各个平台(android.ios.wp.bb.firefoxos.web等几乎所有平台) 手上只有一个android手机 ,安装的时候没有那么顺利,第一大问题就是 ...
- Linux读书笔记1/2章
linux的内核设计: 第一章 1.1Linux历史: 历经时间的考验,今天Unix已经发展成一个支持抢占式多任务.多线程.虚拟内存.换页.动态链接.TCP/Ip网络的现代化操作系统. 1.2追寻Li ...
- 如何使用curl进行网页授权
答:使用curl的-u选项,使用方法如下 curl -u username URL (会提示输入密码)
- python 类和对象的属性
python类和对象的属性分为类属性和对象属性两大类,类属性属于类,而对象属性属于对象. 1. 父类的对象属性会被子类的对象继承. 2. 父类的类属性会被子类继承,还是作为类属性,如果父类改变了类属性 ...