zoukankan      html  css  js  c++  java
  • 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[20];
    const int inf=0x3f3f3f3f;
    const ll infll = 0x3f3f3f3f3f3f3f3fLL;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        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==0)
                break;
            for(int i=1;i<=n;i++)
                scanf("%lf%lf",&a[i].x,&a[i].y),a[i].x*=-1;
            sort(a+1,a+1+n,cmp);
            scanf("%lf/%lf",&x,&y);
            int ans=1;
            double len=cal(a[1]);
            for(int i=2;i<=n;i++)
            {
                double tmp=cal(a[i]);
                //cout<<tmp<<" "<<len<<endl;
                if(tmp<len)
                    ans++;
                len=min(len,tmp);
            }
            cout<<ans<<endl;
        }
    }
  • 相关阅读:
    团队冲刺第九天
    团队冲刺第七天
    CSS 居中大全
    jquery 中fadeIn,fadeOut动画
    使用Fiddler提高前端工作效率 (实例篇)
    使用Fiddler提高前端工作效率 (介绍篇)
    python的一些学习资料(持续更新中)
    Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
    setuptools,pip,install,UnicodeDecodeError: 'ascii' codec can't decode byte.原因和解决方案
    express cookie-session解惑
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4545013.html
Copyright © 2011-2022 走看看