标签:
| Time Limit: 1000MS | Memory Limit: 10000KB | 64bit IO Format: %I64d & %I64u |
Description
Input
Output
Sample Input
3 2 1 2 -3 1 2 1 1 2 0 2 0 0
Sample Output
Case 1: 2 Case 2: 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include<cstdio>#include<algorithm>#include<cmath>using namespace std;const int maxn = 1000 + 10;struct room{ double s,e; bool operator < (const room a)const { return e < a.e || (e == a.e && s > a.s); } }r[maxn];int main(){ int n,d; int cnt = 0; //freopen("out.txt","w",stdout); while(~scanf("%d%d",&n,&d) && (n || d)){ int x,y; int res = 1; for(int i = 0; i < n ;i++ ){ scanf("%d%d",&x,&y); r[i].s = x - sqrt(((double)d*d - y*y)); r[i].e = x + sqrt(((double)d*d - y*y)); if (y > d) res = -1; } if(~res) { sort(r,r+n); room pre = r[0]; for(int i = 1; i < n;i++){ if(r[i].s > pre.e){ res++; pre = r[i]; } } } printf("Case %d: %d\n", ++cnt, res); } return 0;} |
[2016-02-04][POJ][1328][Radar Installation]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/5182437.html