【nyist】6 喷水装置(一) (简单的贪心)

喷水装置(一)

时间限制:3000 ms  |  内存限制:65535 KB
难度:3
描述
现有一块草坪,长为20米,宽为2米,要在横中心线上放置半径为Ri的喷水装置,每个喷水装置的效果都会让以它为中心的半径为实数Ri(0<Ri<15)的圆被湿润,这有充足的喷水装置i(1<i<600)个,并且一定能把草坪全部湿润,你要做的是:选择尽量少的喷水装置,把整个草坪的全部湿润。
输入
第一行m表示有m组测试数据
每一组测试数据的第一行有一个整数数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


解题报告:

    水题一个,放松心情。

ac代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;double a[1000+5];	int main()
{int t,n,ans;double r;cin>>t;while(t--) {ans=0;r=20.0;scanf("%d",&n);for(int i = 0; i<n; i++) {scanf("%lf",&a[i]);}sort(a,a+n,greater<double>() );
//		for(int i = 0; i<n; i++) {
//			printf("%lf",a[i]);
//		}for(int i = 0; i<n; i++) {r-=2*sqrt(a[i]*a[i]-1);ans++;if(r<=0) break;}		printf("%d\n",ans);}return 0 ;} 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/442125.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

layui数据表格获取当前页数

$(".layui-laypage-em").next().html()

最大素因子(不是题目!自己写着玩的。。。)

话不多说直接上代码&#xff1a; #include<iostream> #include<cstring> using namespace std; int res[10000]; int cnt; long long su[100000000]; bool isprime[200000000]; void prime() {memset(isprime,1,sizeof(isprime));cnt1;isprime[0]isprime[1]0;for(i…

.net core 5 IIS Api网站部署需要注意(同.net 6)

应用程序池&#xff1a;.net clr 版本&#xff1a;无托管代码 2.安装.NET Core SDK和AspNetCoreModule托管模块 此工具要在官网直接下载即可

【HDU - 2087】 剪花布条(直接模拟 or KMP)

题干&#xff1a; 一块花布条&#xff0c;里面有些图案&#xff0c;另有一块直接可用的小饰条&#xff0c;里面也有一些图案。对于给定的花布条和小饰条&#xff0c;计算一下能从花布条中尽可能剪出几块小饰条来呢&#xff1f; Input输入中含有一些数据&#xff0c;分别是成…

从客户端*****中检测到有潜在危险的 Request.Form 值。

MVC前端调用后台控制器方法报错 解决方案&#xff1a; //在控制器方法前添加以下修饰 [ValidateInput(false)]

【九度oj 1135】【OpenJ_Bailian - 2915】 字符串排序 (水)

题干&#xff1a; 先输入你要输入的字符串的个数。然后换行输入该组字符串。每个字符串以回车结束&#xff0c;每个字符串少于一百个字符。如果在输入过程中输入的一个字符串为“stop”&#xff0c;也结束输入。 然后将这输入的该组字符串按每个字符串的长度&#xff0c;由小到…

webapi自宿主设置本地端口使用https协议

首先&#xff0c;你要申请证书&#xff0c;然后导入到证书里面&#xff1a; 具体步骤&#xff1a;运行–MMC命令&#xff0c;进入如下界面进行设置&#xff1a; 一直点下一步直到完成&#xff0c;然后将证书导入到个人里面 这个时候进入cmd程序运行如下命令&#xff1a; /…

C# linq Expression left join如何使用

eg&#xff1a; 注意&#xff1a;on 前后要保持字段名一致 var bleftQuery from f in bFamiliesjoin a in bAudits on new{Idf.Id,DCYIdf.ModifyID} equals new{Ida.HealthFamilyId,a.DCYId} into nafrom a in na.DefaultIfEmpty()select new FamilyWithAudit(){Id f.Id,Sea…

第九届(2018)蓝桥杯 山东省赛解题报告(题目+分析+代码)

1标题&#xff1a;第几天 2000年的1月1日&#xff0c;是那一年的第1天。那么&#xff0c;2000年的5月4日&#xff0c;是那一年的第几天&#xff1f; 注意&#xff1a;需要提交的是一个整数&#xff0c;不要填写任何多余内容。 【答案】&#xff1a;125 2标题&#xff1a;明码 …

layui 数据表格 日期格式化

<div>{{ layui.util.toDateString(d.CARDDATE, "yyyy-MM-dd HH:mm:ss") }}</div>

浏览器自带的前进后退按钮禁用

jQuery(document).ready(function () {if (window.history && window.history.pushState) {$(window).on(popstate, function () {/// 当点击浏览器的 后退和前进按钮 时才会被触发&#xff0c; window.history.pushState(forward, null, );window.history.forward(1);…

【HDU - 1241】Oil Deposits (连通块问题 属于求大海中的岛屿个数 类似问题)

题干&#xff1a; The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It t…

asp.net core mvc接口,请求响应统一日志管理

如何为api所有的请求和响应做一个统一的日志记录 1.创建日志类 public class RequestResponseLog {public string Url { get; set; }public IDictionary<string, string> Headers { get; set; } new Dictionary<string, string>();public string Method { get; …

Windows下 Python3.7.0 运行环境的搭建 一套操作后就可以使用Python写代码啦~

1.下载Python for windows 废话不说&#xff0c;直接上网址&#xff1a;https://www.python.org/ftp/python/3.5.1/python-3.5.1.exe 2.安装Python for windows 运行安装文件之后&#xff0c;你会看到这个页面&#xff1a;不得不说Python 在 Windows平台下的安装比傻瓜式还傻瓜…

【HDU - 1873】 看病要排队(优先队列)

题干&#xff1a;看病要排队这个是地球人都知道的常识。 不过经过细心的0068的观察&#xff0c;他发现了医院里排队还是有讲究的。0068所去的医院有三个医生&#xff08;汗&#xff0c;这么少&#xff09;同时看病。而看病的人病情有轻重&#xff0c;所以不能根据简单的先来先服…

h5 网站滚动到某个位置

var height $("#0107").offset().top&#xff1b; //获得要滚动到的高度 $("html:not(:animated),body:not(:animated)").animate({ scrollTop: 392 }, slow); //滚动

【HDU - 1856】 More is better(并查集)(还需要空间优化。。)

题干&#xff1a;Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wang selected a room big enough to hold the boys. The boy who…

.Net开发WebApi如何使用JObject对象接收参数

1.需要引入包Microsoft.AspNetCore.Mvc.NewtonsoftJson 2.在StartUp.cs的ConfigureServices方法中进行注册 services.AddControllers().AddNewtonsoftJson(options >{options.SerializerSettings.ContractResolver new DefaultContractResolver();}); 3.前端ajax使用 $.aja…

【HDU - 1326】Box of Bricks(模拟水题)

题干&#xff1a;Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. Look, Ive built a wall!, he tells his older sister Alice. Nah, you should make all stacks the same height. Then you …

微信公众平台网站开发JS_SDK遇到的bug——wx.config注册提示成功,但部分接口注册失败问题

1 2022-02-23 使用微信公众平台调用扫一扫接口&#xff0c;总是注册不成功 这是进行注册后成功注册的接口提示 尝试注册了以下接口 拥有相关权限 解决办法&#xff1a;猜测失败原因为&#xff1a;子界面进行注册&#xff0c;在父界面进行注册后&#xff0c;成功