栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2976 Light Bulbs

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2976 Light Bulbs

#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<algorithm>#include<string>#include<map>#include<set>#include<iostream>#include<vector>#include<queue>using namespace std;#define sz(v) ((int)(v).size())#define rep(i, n) for (int i = 0; i < (n); ++i)#define repf(i, a, b) for (int i = (a); i <= (b); ++i)#define repd(i, a, b) for (int i = (a); i >= (b); --i)#define clr(x) memset(x,0,sizeof(x))#define clrs( x , y ) memset(x,y,sizeof(x))#define out(x) printf(#x" %dn", x)#define sqr(x) ((x) * (x))typedef long long lint;const int maxint = -1u>>1;const double eps = 1e-8;const int maxn = 100 + 10;int sgn(const double &x) { return (x > eps) - (x < -eps); }double xx[maxn], yy[maxn], zz[maxn], ll[maxn];int n;double gao(double ox, double oy) { double ma = 0; rep (i, n) { double dis; double x, y, z, l; x = xx[i] - ox; y = yy[i] - oy; z = zz[i]; l = ll[i]; dis = y * y + x * x + z * z; double c = z / sqrt(dis); double res = l / (dis) * c; ma += res; } return ma;}int main() { int T; scanf("%d", &T); while (T--) { scanf("%d", &n); double ma = 0; rep (i, n) scanf("%lf%lf%lf%lf", &xx[i], &yy[i], &zz[i], &ll[i]); repf (i, -100, 100) repf (j, -100, 100) { double tmp = gao(i, j); ma = max(tmp, ma); } printf("%.2fn", ma); } return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378654.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号