首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Uva 10382(nyist 12喷水设备二)

2012-11-26 
Uva 10382(nyist 12喷水装置二)#include iostreamusing namespace std#includecmath#include cstdio

Uva 10382(nyist 12喷水装置二)

#include <iostream>using namespace std;#include<cmath>#include <cstdio>struct point{    float l,r;}p[10005];int main(int argc, char *argv[]){    float w,h,s,x1,x,r,x2;    int i,n,ans;    while (scanf("%d%f%f",&n,&w,&h)!=EOF) //nyist 有组数输入     {           i=0;h=h/2;        while (n--)        {            scanf("%f%f",&x,&r);            if (r>=h)            {                s=sqrt(r*r-h*h);                x1=x-s;                x2=x+s;                p[i].l=x1;                p[i++].r=x2;            }        }        n=i;ans=0;        float start=0,end=w,maxr;        while(start<end)        {   maxr=0;        for(i=0;i<n;i++)           if(p[i].l<=start&&p[i].r>maxr)        maxr=p[i].r;        if(maxr==start) {ans=-1;break;} //nyist 12是:ans=0;         ans++;        start=maxr;        }        cout<<ans<<endl;    }    return 0;}

热点排行