cdoj 26 遮挡判断(shadow) 水题
遮挡判断(shadow)
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.uestc.edu.cn/#/problem/show/26
Description
在一个广场上有一排沿着东西方向排列的石柱子,阳光从东边以一定的倾角射来(平行光)。有的柱子可能被在他东边的高大的柱子的影子给完全遮挡住了。现在你要解决的问题是求出有多少柱子是没有被完全遮挡住的。
假设每个石柱子是一根细棒,而且都垂直于地面摆放。
Input
输入包含多组数据。每组数据第一行是一个整数N(0<N≤100000),表示柱子的个数。N=0代表输入结束。接下来有N行,每行是两个整数,分别给出每根柱子的水平位置X和高度H(X越大,表示越在西边,0≤X≤10000000,0<H≤10000000保证不会有两根柱子在同一个X坐标上)。最后有一行,以分数的形式给出太阳光与地面的夹角的正切值T/A(1≤A,T≤10)。
Output
对每组数据,输出包含所求数目的一行。
Sample Input
4
0 3
3 1
2 2
1 1
1/1
0
Sample Output
2
HINT
题意
题解:
首先排一个序,然后从东往西做比较,如果右边的影子能把左边的影子覆盖,那么说明左边就被挡住了
然后我们不断更新最往西的影子长度,然后O(n)跑一法就好了
水题
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200000
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** struct node
{
double x,y;
};
bool cmp(node a,node b)
{
return a.x>b.x;
}
node a[maxn];
int n;
double x,y;
double cal(node e)
{
return e.x-e.y*y/x;
}
int main()
{
//test;
while(cin>>n)
{
if(n==)
break;
for(int i=;i<=n;i++)
scanf("%lf%lf",&a[i].x,&a[i].y),a[i].x*=-;
sort(a+,a++n,cmp);
scanf("%lf/%lf",&x,&y);
int ans=;
double len=cal(a[]);
for(int i=;i<=n;i++)
{
double tmp=cal(a[i]);
//cout<<tmp<<" "<<len<<endl;
if(tmp<len)
ans++;
len=min(len,tmp);
}
cout<<ans<<endl;
}
}
cdoj 26 遮挡判断(shadow) 水题的更多相关文章
- 蓝桥杯 第四届C/C++预赛真题(5) 前缀判断(水题)
题目标题:前缀判断 如下的代码判断 needle_start指向的串是否为haystack_start指向的串的前缀,如不是,则返回NULL. 比如:"abcd1234" 就包含了 ...
- ZJU 1180 Self Numbers(暴力模拟判断,水题)
题目链接 同HDU 1128 , POJ 1316(这个范围小一点). 原本怕超时,以为有技巧或者规律,死命的想,后来发现这就是一道水体,模拟着全部判断一下就好了,10秒呢,完全不怕超时...唔,废话 ...
- HDU 2108 逆时针给出多边形的顶点,判断是否为凸多边形,水题
下面是别人解题报告的链接,很详细,写的很好 http://blog.csdn.net/chl_3205/article/details/8520597 下面贴我的代码 #include <cst ...
- hrbustoj 1306:再遇攻击(计算几何,判断点是否在多边形内,水题)
再遇攻击 Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 253(37 users) Total Accepted: 56(2 ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
- cdoj 24 8球胜负(eight) 水题
8球胜负(eight) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...
- hdu3793 判断对称(水题)
题意: 给你一个串,问你这个串是不是关于某个字母对称的,这个串是一个首位相接的圆. 思路: 水题,直接枚举每一个为对称点试一下就行了,不解释了. #include<std ...
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
随机推荐
- Oracle VirtualBox 模拟Android系统 素材
Android to x86 下载地址: http://www.android-x86.org/download VirtualBox 下载地址: https://www.virtualbox.org ...
- Web前端开发工程师编程能力飞升之路
[背景] 如果你是刚进入web前端研发领域,想试试这潭水有多深,看这篇文章吧:如果你是做了两三年web产品前端研发,迷茫找不着提高之路,看这篇文章吧:如果你是四五年的前端开发高手,没有难题能难得住你的 ...
- 【LeetCode】223 - Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- (转载)OC学习篇之---代理模式
在前一篇文章我们介绍了OC中的协议的概念,这篇文章我们就来介绍一下OC中的代理模式,关于代理模式,如果还有同学不太清楚的话,就自己去补充知识了,这里就不做介绍了,这里只介绍OC中是如何实现代理模式的. ...
- How To Set Up Port Forwarding in Linux
Port forwarding usually used when we want our computer act like a router. Our computer receive the p ...
- dom div移动解决停顿问题
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 第二百零八天 how can I 坚持
今天徐斌生日,生日快乐.买了两个小蛋糕,哈哈 还买了两条熊猫鱼.不知道鱼会不会冻死啊,买了加热器又不想用,看他们造化吧. LOL不错的游戏的. 睡觉,好冷.
- EntityFramwork6连接MySql错误
EntityFramwork6连接MySql错误 使用EF6连接MySql产生Exception: ProHub.ssdl(2,2) : 错误 0152: MySql.Data.MySqlClient ...
- cvc-elt.1: Cannot find the declaration of element 'beans'
@(编程) 现象描述 导入的一个eclipse项目报错,各种方法都无法解决,报错信息如下: cvc-elt.1: Cannot find the declaration of element 'bea ...
- Socket小项目的一些心得(鸣谢传智的教学视频)
Socket是一种封装了四层通信的整体抽象入口,通常也称作"套接字",这是常用的四层通信这是访问Socket的流程图,这个分为客户端和服务器端,其中服务器端有以下步骤去建立,前面的 ...