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

做一个输出一个,不要攒起来,可能超过1000个

Posted by lympanda at 2004-11-23 20:14:28 on Problem 1046
In Reply To:Help Posted by:simon0524cn at 2004-11-23 19:10:37
> #include<stdio.h>
> #include<math.h>
> void main(){
> 	#define N 16
> 	struct point{
> 		int r;
> 		int g;
> 		int b;
> 	}point[16];
> 	int i,D[N],min,j,k,p;
> 	for(i=0;i<N;i++){
> 	scanf("%d %d %d",&point[i].r,&point[i].g,&point[i].b);
> 	}
> 	int x[1000],y[1000],z[1000],l[1000],m[1000],n[1000];
> 	for(k=0;k<1000;k++)
> 	{
>         scanf("%d %d %d",&x[k],&y[k],&z[k]);
> 	    if(x[k]!=-1&&y[k]!=-1&&z[k]!=-1){
> 		   for(i=0;i<N;i++){
> 			   D[i]=(point[i].r-x[k])*(point[i].r-x[k])+(point[i].g-y[k])*(point[i].g-y[k])+(point[i].b-z[k])*(point[i].b-z[k]);
> 		   }
> 		   min=D[0];
> 		   for(j=0;j<N;j++){
> 			   if(min>=D[j]){min=D[j];l[k]=point[j].r;m[k]=point[j].g;n[k]=point[j].b;}
> 		   }  
> 		}
> 		else break;
> 	}
>     for(p=0;p<k;p++){ 
> 	    printf("(%d,%d,%d) maps to (%d,%d,%d)\n",x[p],y[p],z[p],l[p],m[p],n[p]);
> 	}
> }
> 那位大哥大姐帮忙看一下,为什么总是Wrong answer 啊?

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