POJ1328
来源:互联网 发布:js中动态生成表格 编辑:程序博客网 时间:2024/05/21 17:19
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
using namespace std;
struct point
{
double x,y;
}stl[1005];
struct node
{
double x1,x2;
}cir[1005];
int cmp( point a, point b)
{
if(a.x != b.x)
return a.x<b.x;
return a.y < b.y;
}
int main()
{
int n,d;
int ans = 0;
int count = 0;
while(scanf("%d %d",&n, &d), n != 0 && d != 0)
{
count++;
bool falg = false;
ans = 1;
for( int i = 0; i<n; i++)
scanf("%lf %lf",&stl[i].x, &stl[i].y);
sort(stl,stl+n,cmp);
if(stl[0].y - d > 0 || stl[0].y + d < 0)
falg = true;
cir[0].x1 = stl[0].x - d;
cir[0].x2 = stl[0].x + d;
cir[0].x1 = -(sqrt(d*d - stl[0].y * stl[0].y)) + stl[0].x;
cir[0].x2 = (sqrt(d*d - stl[0].y * stl[0].y)) + stl[0].x;
for( int i = 1; i<n; i++)
{
if(stl[i].y - d > 0 ||stl[i].y + d < 0)
falg = true;
if(falg)
break;
cir[i].x1 = -(sqrt(d*d - stl[i].y * stl[i].y)) + stl[i].x;
cir[i].x2 = (sqrt(d*d - stl[i].y * stl[i].y)) + stl[i].x;
if(cir[i-1].x2 < cir[i].x1)
ans++;
else
{
cir[i].x1 = max(cir[i-1].x1 , cir[i].x1);
cir[i].x2 = min(cir[i-1].x2,cir[i].x2);
}
}
if(!falg)
cout<<"Case "<<count<<": "<<ans<<endl;
else
cout<<"Case "<<count<<": "<<"-1"<<endl;
}
}
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
using namespace std;
struct point
{
double x,y;
}stl[1005];
struct node
{
double x1,x2;
}cir[1005];
int cmp( point a, point b)
{
if(a.x != b.x)
return a.x<b.x;
return a.y < b.y;
}
int main()
{
int n,d;
int ans = 0;
int count = 0;
while(scanf("%d %d",&n, &d), n != 0 && d != 0)
{
count++;
bool falg = false;
ans = 1;
for( int i = 0; i<n; i++)
scanf("%lf %lf",&stl[i].x, &stl[i].y);
sort(stl,stl+n,cmp);
if(stl[0].y - d > 0 || stl[0].y + d < 0)
falg = true;
cir[0].x1 = stl[0].x - d;
cir[0].x2 = stl[0].x + d;
cir[0].x1 = -(sqrt(d*d - stl[0].y * stl[0].y)) + stl[0].x;
cir[0].x2 = (sqrt(d*d - stl[0].y * stl[0].y)) + stl[0].x;
for( int i = 1; i<n; i++)
{
if(stl[i].y - d > 0 ||stl[i].y + d < 0)
falg = true;
if(falg)
break;
cir[i].x1 = -(sqrt(d*d - stl[i].y * stl[i].y)) + stl[i].x;
cir[i].x2 = (sqrt(d*d - stl[i].y * stl[i].y)) + stl[i].x;
if(cir[i-1].x2 < cir[i].x1)
ans++;
else
{
cir[i].x1 = max(cir[i-1].x1 , cir[i].x1);
cir[i].x2 = min(cir[i-1].x2,cir[i].x2);
}
}
if(!falg)
cout<<"Case "<<count<<": "<<ans<<endl;
else
cout<<"Case "<<count<<": "<<"-1"<<endl;
}
}
0 0
- POJ1328
- poj1328
- POJ1328
- poj1328
- POJ1328
- poj1328
- poj1328
- poj1328
- poj1328
- poj1328
- poj1328
- poj1328
- poj1328
- POJ1328
- POJ1328
- POJ1328
- poj1328
- POJ1328
- JDBC Connection Reset问题分析
- <<Oracle Applications DBA 基础(第二期)>>Week 15 exercise
- swfupload组件后台获取中文文件名乱码的问题解决
- 黑马程序员----Overload和Override、可变参数、枚举
- 黑马程序员--IO流(下)
- POJ1328
- Dirichlet's Theorem on Arithmetic Progressions
- 神经网络与SVMs在医学领域的应用实例
- openstack_ice之wsgi详解(paste从ini配置文件->routesr具体发布流程)
- 一个C语言程序的编译过程
- UVA10785 The Mad Numerologist
- Win7下编译Hadoop1.2.1源码
- 【转载】ACE中的Double Checked Locking模式
- 第九章 两种模式的比较