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 longlong6789 at 2008-07-18 20:57:29 on Problem 1046
#include<stdio.h>
#include<math.h>
int main()
{
    int r[16],g[16],b[16],R,G,B,i=1,j=0,k;
    double d,p;
    do
    {
      scanf("%d%d%d",&R,&G,&B);
      if(j>15)
      {
         d=sqrt((r[0]-R)*(r[0]-R)+(g[0]-G)*(g[0]-G)+(b[0]-B)*(b[0]-B));
         k=0;
         for(i=1;i<16;i++)
         {
           p=sqrt((r[i]-R)*(r[i]-R)+(g[i]-G)*(g[i]-G)+(b[i]-B)*(b[i]-B));
           if(d>p)
           {
             d=p;
             k=i;
           }
         }
       printf("(%d,%d,%d) maps to (%d,%d,%d)\n",R,G,B,r[k],g[k],b[k]);
      }
      else
      {
        r[j]=R;
        g[j]=G;
        b[j]=B;
        j++;
      }        
    }while(R!=-1||G!=-1||B!=-1);
    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