【贪心】时空定位I
【贪心】时空定位I
题目描述
输入
每一组测试数据的第一行有一个整数数n,n表示共有n个定位装置,随后的一行,有n个实数Ri,Ri表示该定位装置能覆盖的圆的半径。
输出
样例输入
2
5
2 3.2 4 4.5 6
10
1 2 3 1 2 1.2 3 1.1 1 2
样例输出
2
5
分析:依次选取半径最大的雷达即可;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e3+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,cnt;
double a[maxn],now;
int main()
{
int i,j,k,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
rep(i,,n-)scanf("%lf",&a[i]);
sort(a,a+n);
cnt=;now=;
for(i=n-;i>=;i--)
{
if(now>=)break;
now+=*sqrt(a[i]*a[i]-);
cnt++;
}
printf("%d\n",cnt);
}
//system ("pause");
return ;
}
【贪心】时空定位I的更多相关文章
- 【贪心】时空定位II
[贪心]时空定位II 题目描述 有一块空间,横向长w,纵向长为h,在它的横向中心线上不同位置处装有n(n≤10000)个点状的定位装置,每个定位装置i定位的效果是让以它为中心半径为Ri的圆都被覆盖.请 ...
- Noip2019暑期训练1
题目名称 时空定位 棋子移动 高精度乘法 数独游戏 存盘文件名 location piece mul sudoku 输入文件名 location.in piece.in mul.in sudoku.i ...
- python与正则表达式
匹配一个字符: . 任意非\n字符 [...] \d \D digit \s \S space \w \W word 匹配前一个字符的多个: * 0->> + 1->> ? 0 ...
- ### Paper about Event Detection
Paper about Event Detection. #@author: gr #@date: 2014-03-15 #@email: forgerui@gmail.com 看一些相关的论文. 1 ...
- ###《High-level event recognition in unconstrained videos》
Author: Yu-Gang Jiang, Shih-Fu Chang 事件检测的目标就是自动识别给定视频序列中的感兴趣事件.进行视频事件检测通常很困难,特别是在网络中非限制的视频.在非限制情况下, ...
- HDU 4023 (博弈 贪心 模拟) Game
如果硬要说这算是博弈题目的话,那这个博弈是不公平博弈(partizan games),因为双方面对同一个局面做出来的决策是不一样的. 我们平时做的博弈都是公平博弈(impartial games),所 ...
- URL锚点HTML定位技术机制
一.锚点是什么 锚点就等同于火影中的“飞雷神之术”,我们先看百科中锚点的解释: 使用命名锚记可以在文档中设置标记,这些标记通常放在文档的特定主题处或顶部.然后可以创建到这些命名锚记的链接,这些链接可快 ...
- uoj #2 【NOI2014】起床困难综合症 贪心+位运算
题目链接 给出n个数, 每个数有特定的一种操作, &|^三种, 给出一个m, 初始值属于[0,m],选定一个初始值, 使所有操作做完之后的值最大, 输出这个最大值. 1, 从最高位贪心, 如果 ...
- 个人总结-----非贪心算法的图的m着色判断及优化问题
1.问题描述: 对于著名的图的m着色,有两个主要的问题,一个是图的m色判定问题,一个是图的m色优化问题,描述如下. 图的m色判定问题: 给定无向连通图G和m种颜色.用这些颜色为图G的各顶点着色.问是否 ...
随机推荐
- C语言-字符串文本串联
要形成包含多个行的字符串,可以串联两个字符串. 为此,请键入正斜杠,然后按 return 键. 反斜杠导致编译器忽略以下换行符. 例如,字符串 "Long strings can b ...
- WIN2003 设置 OPENVPN 服务端
服务器端 安装openvpn 在这里http://swupdate.openvpn.org/community/releases/openvpn-install-2.3.4-I004-i686.exe ...
- java 正则
ava - 正则表达式 - Pattern - Matcher 2013-08-21 14:35 3325人阅读 评论(0) 收藏 举报 分类: JavaSE(30) 版权声明:本文为博主原创文章 ...
- ios 烟花 火焰 雨水 雪花等特效属性
CAEmitterLayer *snowEmitter = [CAEmitterLayer layer]; //例子发射位置 snowEmitter.emitterPosition = CGPoint ...
- login/logout切换
1. 前端按钮 <img border="0" width="18" height="18" src="<%=base ...
- 其他信息: Error creating context 'spring.root': 未能加载文件或程序集“EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”或它的某一个依赖项
详细错误情况: “System.Configuration.ConfigurationErrorsException”类型的异常在 Spring.Core.dll 中发生,但未在用户代码中进行处理 其 ...
- iptables基础知识
iptables防火墙可以用于创建过滤(filter)与NAT规则.所有Linux发行版都能使用iptables,因此理解如何配置 iptables将会帮助你更有效地管理Linux防火墙.如果你是第一 ...
- PCI-E调试方式
PCI-E的调试步骤 1.板子插上去之后正常情况下使用lspci 就能看的一个设备 这个设备上存在几个ID,可以根据ID可以确定设备是否识识别到 2.然后就是加载设备的驱动的时候,设备驱动会有VEND ...
- Ztree当节点没有下级时不显示下拉图标
select o.*,(select count(*) from sys_org t where t.orgsupid=o.orgid) isLeaf from sys_org o where 1=1
- html屏蔽右键、禁止复制与禁止查看源代码
<script> function doNothing(){ window.event.returnValue=false; return false; } </script> ...