Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求诸位大牛们帮小弟看看 数据过了 为什么wa呢

Posted by 565908262 at 2013-01-23 08:21:52 on Problem 1328
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
    double x;
    double y;
} p[100000];
int cmp(node a,node b)
{
    return  a.x<b.x;
}
int main()
{
    int n,d,a[100000],b[100000],po=0;
    while(scanf("%d%d",&n,&d)!=EOF &&(n||d))
    {
        if(n!=0&&d!=0)
        {po++;
        int sum=1,i;
        for(i=0; i<n; i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            p[i].x=a[i]-sqrt(d*d*1.00-b[i]*b[i]*1.00);
            p[i].y=a[i]+sqrt(d*d*1.00-b[i]*b[i]*1.00);
        }
        sort(p,p+n,cmp);
        double q=p[0].y;
        int u;
        for(u=1; u<n; u++)
        {
            if(p[u].y<q)
                q=p[u].y;
            else if(p[u].x>q)
            {
                sum++;
                q=p[u].y;
            }
        }
            printf("Case %d: %d\n\n",po,sum);}
            else
            break;
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator