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

Re:哪位大牛帮我看看到底错哪里了?为什么所有数据测出来都是对的交上去是WA

Posted by huJJ at 2012-02-03 13:46:07 on Problem 1328
In Reply To:哪位大牛帮我看看到底错哪里了?为什么所有数据测出来都是对的交上去是WA Posted by:Hankauk at 2011-11-25 21:10:17
> #include <iostream>
> #include<cmath>
> #include<algorithm>
> #include<stdio.h>
> using namespace std;
> struct dot
> {
>     double x1;
>     double x2;
> }radar[1009];
> bool cmp(dot a,dot b)
> {
>     return a.x1<b.x1;
> }
> int main()
> {
>     freopen("in.txt","r",stdin);
>     double s;
>     int n,d,i;
>     int j=0;
>     int sum,flag;
>     double dots[1009][2];
>     while(cin>>n>>d&&n+d>0)
>     {
>         flag=1;sum=1;
>         if(d<0) flag=0;
>         for(i=0;i<n;i++)
>             cin>>dots[i][0]>>dots[i][1];
>         for(i=0;i<n;i++)
>             if(dots[i][1]>d)
>                 flag=0;
>         if(flag==0)
>         {
>             j++;
>             cout<<"case "<<j<<": "<<"-1"<<endl;
>             continue;
>         }
>         for(i=0;i<n;i++)
>         {
>             s=sqrt(d*d-dots[i][1]*dots[i][1]);
>             radar[i].x1=dots[i][0]-s;
>             radar[i].x2=dots[i][0]+s;
>         }
>         sort(radar,radar+n,cmp);
>         for(flag=0,i=1;i<n;i++)
>         {
>             if(radar[flag].x2>=radar[i].x1)
>             {
>                 if(radar[i].x2<=radar[flag].x2)
>                 flag=i;
>             }
>             if(radar[flag].x2<radar[i].x1)
>             {
>                 flag=i;
>                 sum++;
>             }
>         }
>         j++;
>         cout<<"case "<<j<<": "<<sum<<endl;
>     }
>     return 0;
> }

当n=3 d=-3的时候,n+d=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