Watering Grass】的更多相关文章

Problem E Watering Grass Input: standard input Output: standard output Time Limit: 3 seconds n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the s…
UVa 10382 - Watering Grass n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its position as the distance…
Watering Grass n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its position as the distance from the le…
n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its position as the distance from the left end of the c…
n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its position as the distance from the left end of the c…
给定一条草坪.草坪上有n个喷水装置.草坪长l米宽w米..n个装置都有每个装置的位置和喷水半径..要求出最少需要几个喷水装置才能喷满草坪..喷水装置都是装在草坪中间一条水平线上的. n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the stri…
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/E 题意: 给定一条草坪,草坪上有n个喷水装置.草坪长l米宽w米,n个装置都有每个装置的位置和喷水半径.要求出最少需要几个喷水装置才能喷满草坪.喷水装置都是装在草坪中间一条水平线上的. 案例: Sample Input8 20 25 34 11 27 210 213 316 219 43 10 13 59 36 13 10 15 31 19 1Samp…
和 Uva 10020几乎是一样的,不过这里要把圆形区域转化为能够覆盖的长条形区域(一个小小的勾股定理) 学习一下别人的代码,练习使用STL的vector容器 这里有个小技巧,用一个微小量EPS来弥补浮点运算中的误差 //#define LOCAL #include <vector> #include <cstdio> #include <cmath> #include <algorithm> #include <functional> usin…
Sample Input 8 20 2 5 3 4 1 1 2 7 2 10 2 13 3 16 2 19 4 3 10 1 3 5 9 3 6 1 3 10 1 5 3 1 1 9 1 Sample Output 6 2 -1 题目大意: 有一块草坪,长为l,宽为w,在它的水平中心线上有n个位置可以安装喷水装置,各个位置上的喷水装置的覆盖范围为以它们自己的半径ri为圆.求出最少需要的喷水装置个数.   分析与总结: 这题的关键在于转化 根据这图可以看出,一个喷水装置的有效覆盖范围就是圆中间的那…
题目大意:有一条长为l,宽为w的草坪,在草坪上有n个洒水器,给出洒水器的位置和洒水半径,求能浇灌全部草坪范围的洒水器的最小个数. 经典贪心问题:区间覆盖.用计算几何对洒水器的覆盖范围简单处理一下即可得到每个区间的范围,剩下的就是区间覆盖了.可参考UVa 10020 - Minimal coverage #include <cstdio> #include <cmath> #include <algorithm> using namespace std; #define…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1323 题意 长方形l * w,给出长方形中间那条线上n个圆的圆心c和半径r,选取最少数目的圆覆盖长方形,选不了输出-1 思路 明显,算出圆在边上的坐标,然后尽量从左向右扩展就行 感想: 卡题的原因是反射性以为r和w很小,但其实可以很大,所以用double存r 代码 #include…
题意:有一块草坪,这块草坪长l 米,宽 w 米,草坪有一些喷头,每个喷头在横坐标为 p 处,每个喷头的纵坐标都是(w/2) ,并且喷头的洒水范围是一个以喷头为圆心,半径为 r 米的圆.每次最少需要打开多少个喷头来给草坪洒水,并且草坪各处都能被洒到,不行输出-1 思路:这是一道区间覆盖(贪心)题: 有一堆区间 l1, r1:l2, r2...ln,rn,问你最少用几个能覆盖0~P的长度 那么我们先按照L升序排序,far是目前所能找到的最远处,R是上一次查询所能找到的最远处,每次查询我们都要找后面满…
喷水装置的圆心和半径确定,就能确定左端和右端.开始时pos=0,选取左端小于pos,右端最大的更新pos. #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <iomanip> #include <cstring> #include <map> #inclu…
题意:有一块长为l,宽为w的草地,在其中心线有n个喷水装置,每个装置可喷出以p为中心以r为半径的圆, 选择尽量少的装置,把草地全部润湿. 析:我个去啊,做的真恶心,看起来很简单,实际上有n多个坑啊,首先这个题,应该可以看出来是贪心算法, 具体的说是区间覆盖问题,这个问题总体来说不难,但是在这有了巨多的坑.要注意以下几点: 1.这是一个草坪,不是线段,首先你要先把实验室转化为线段. 2.这个喷水装置喷出是圆,不是矩形,要运用数学知识进行运算. 3.输入的半径的两倍如果小于等于宽度,就得忽略不记.因…
问题可以转化为草坪的边界被完全覆盖.这样一个圆形就换成一条线段. 贪心,从中选尽量少的线段把区间覆盖,按照把线段按左端点排序,记录一个当前已经覆盖区间的位置cur, 从左端点小于等于cur选一个右端点最大的作为这次选的区间,如果没有符合条件的,说明不可能完全覆盖. r*r会爆int... #include<bits/stdc++.h> using namespace std; ; int n,l,w; struct seg { double l,r; bool operator < (c…
贪心算法. #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <vector> #include <algorithm> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?…
参考: https://blog.csdn.net/shuangde800/article/details/7828675 https://www.cnblogs.com/haoabcd2010/p/6171794.html?utm_source=itdadao&utm_medium=referral #include <iostream> #include <stdio.h> #include <cstring> #include <cmath>…
题意:有一个矩形,n个圆.已知矩形的长宽和圆的半径,问最少需多少个圆将矩形完全覆盖. 分析: 1.首先求圆与矩形的长的交点,若无交点,则一定不能对用最少的圆覆盖矩形有贡献. 2.如果两个圆与矩形相交所得的线段重合,那这两个圆一定能把矩形在两线段并集的那部分所覆盖.问题转化为用圆与矩形相交所得的线段覆盖矩形的长. 3.按线段左端点排序,对于某个已选择的线段a,求它后面满足b.L <= a.R的线段b的b.R的最大值,依次类推. #include<cstdio> #include<cs…
10382 - Watering Grass Time limit: 3.000 seconds n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its po…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…
10382 - Watering Grass Time limit: 3.000 seconds n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are given its po…
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2145    Accepted Submission(s): 1622 Problem Description 大学时光是浪漫的,女生是浪漫的,圣诞更是浪漫的,但是Rabbit和Grass这两个大学女生在今年的圣诞节却表现得一点都不浪漫:不去逛商场,不去逛…
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3864    Accepted Submission(s): 2919 Problem Description 大学时光是浪漫的,女生是浪漫的,圣诞更是浪漫的,但是Rabbit和Grass这两个大学女生在今年的圣诞节却表现得一点都不浪漫:不去逛商场,不去逛…
C. Watering Flowers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r…
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), giving the distances at which t…
水题,转化Nim 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1.0) #define MAX 50000 using namespa…
3479: [Usaco2014 Mar]Watering the Fields Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 81  Solved: 42[Submit][Status] Description Due to a lack of rain, Farmer John wants to build an irrigation system to send water between his N fields (1 <= N <=…
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2254    Accepted Submission(s): 1704 Problem Description 大学时光是浪漫的,女生是浪漫的,圣诞更是浪漫的,可是Rabbit和Grass这两个大学女生在今年的圣诞节却表现得一点都不浪漫:不去逛商场,不去…
MST...一开始没注意-1结果就WA了... ---------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<iostream>   #define r…
题解:因为棋子可重叠,所以就等于取石子问题,即尼姆博弈,SG[i]=i,直接将输入数据异或即可. #include <cstdio> int main(){ int SG,n,a; while(scanf("%d",&n),n){ SG=0; while(n--){ scanf("%d",&a); SG=SG^a; } if(SG==0)printf("Grass Win!\n"); else printf("…