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 lmh463896910 at 2012-12-13 14:09:51 on Problem 1328
RT
代码如下  谢谢
#include <iostream>
#include <cstdio>
#include <cmath>
#define yn yn1
using namespace std;
int xn[1005],yn[1005];
double cn[1005],dn[1005];
int n,d;

int radar()
{
    int i,j;
    int dd = d * d;
    bool xxx = true;
    for(i = 1;i <= n;i ++)
    {
        scanf("%d%d",&xn[i],&yn[i]);
        if(yn[i] > d || yn[i] < 0)
        {
            xxx = false;
        }
        cn[i] = xn[i] + 0.0 - sqrt(dd - yn[i] * yn[i] + 0.0);
        dn[i] = xn[i] + 0.0 + sqrt(dd - yn[i] * yn[i] + 0.0);

    }
    //for(i = 1;i <= n;i ++) printf("%d %d\n",xn[i],yn[i]);
    //for(i = 1;i <= n;i ++) printf("%d %d %lf %lf %lf %lf\n",xn[i],yn[i],an[i],bn[i],cn[i],dn[i]);
    if(xxx)
    {
        int t;
        for(i = 1;i <= n;i ++)
            for(j = 1;j <= n - i;j ++)
            {
                if(cn[j] > cn[j + 1])
                {
                    t = cn[j];
                    cn[j] = cn[j + 1];
                    cn[j + 1] = t;
                    t = dn[j];
                    dn[j] = dn[j + 1];
                    dn[j + 1] = t;
                }
            }
        //for(i = 1;i <= n;i ++) printf("%lf %lf\n",cn[i],dn[i]);
        int min1 = 0,x1 = 1;
        bool xxxx = false;
        if(1 == n) min1 = 1;
        else
        {
            for(i = 2;i <= n;i ++)
            {
                for(j = 1;j <= n;j ++)
                if(cn[i] - dn[j] >= 0.000001) xxxx = true;
                if(xxxx)
                {
                    min1 ++;
                    for(int x2 = 1;x2 < i;x2 ++) dn[x2] =cn[n] + 1.0;
                }
                xxxx = false;

            }
            min1 ++;
        }
        return min1;
    }
    else return -1;
}

int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int cas = 0;
    scanf("%d%d",&n,&d);
    while(n != 0)
    {
        int min1 = radar();
        printf("Case %d: %d\n",++ cas,min1);
        scanf("%d%d",&n,&d);
        //printf("n,d:%d %d\n",n,d);
    }
    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