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 ecjtuFFF at 2008-10-15 20:27:57 on Problem 1046
In Reply To:哪位帮忙看下程序,为什么总是WA Posted by:XQQ at 2006-12-09 11:17:54
> #include<iostream>
> #include<cstdlib>
> using namespace std;
> int a[16][3];
> long color(int i,int b[]){
>        long sum=0;
>        for(int j=0;j<3;j++)
>            sum+= (a[i][j]-b[j])*(a[i][j]-b[j]);
>        return sum;
> }
> int main(){
>     int t=0;
>     while(t++<16) 
>           scanf("%d %d %d",&a[t][0],&a[t][1],&a[t][2]);
>     int b[3];
>     while(scanf("%d %d %d",&b[0],&b[1],&b[2])) {
>                     if(b[0]==-1&&b[1]==-1&&b[2]==-1) return 0;
>                     long  k=3000000;//初始化最小值
>                     int tt;
>                     for(int i=0;i<16;++i)
>                           if(k>color(i,b)){k=color(i,b);tt=i;}
>                     printf("(%d,%d,%d) maps to (%d,%d,%d)\n",
>                             b[0],b[1],b[2],a[tt][0],a[tt][1],a[tt][2]);
>                             }
>     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