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

郁闷了,c++提交OLE, G++提交 WA,到底是哪里大问题,各位帮我看看到底是哪里的问题

Posted by sunmoonstar_love at 2005-07-06 20:32:03 on Problem 2466
In Reply To:郁闷了,c++提交OLE, G++提交 WA,到底是哪里大问题,各位帮我看看到底是哪里的问题 Posted by:sunmoonstar_love at 2005-07-06 18:11:17
> #include <stdio.h>
> #include <algorithm>// _int64  long long
> _int64 n,i,j,k,ns,sum[37],tmp,len,a[10];
> bool b[37],Im;
> int main()
> {
>     b[0] = b[1] = true;
>     while(scanf("%I64d",&n)!= EOF)
>     {
>         ns = n*(n-1)/2;
>         for(i=0; i<ns; i++)
>         {
>             scanf("%I64d",&sum[i]);
>             b[i] = false;
>         }
>         std::sort(sum,sum+ns);
>         Im = true;
>         for(i=2; i<ns; i++)
>         {
>             a[2] = (sum[1] - sum[0] + sum[i])/2;
>             a[1] = sum[i] - a[2];
>             a[0] = sum[0] - a[1];
>             if(a[2]*2 != sum[1] - sum[0] + sum[i])
>                 continue;
>             len = 3;
>             b[i] = true;
>             for(j=2; j<ns; j++)
>             {
>                 if(!b[j])
>                 {
>                     a[len++] = sum[j] - a[0];
>                     b[j] = true;
>                     tmp = 1;
>                     for(k=j+1; k<ns&&tmp<len-1; k++)
>                     {
>                         if(!b[k]&&(a[tmp]+a[len-1] == sum[k]))                
>                         {
>                             b[k]=true;
>                             tmp++; 
>                         }                           
>                     }    
>                 }    
>             }
>             if(len==n)
>             {
>                 Im = false;
>                 break;
>             }    
>             for(k=2; k<ns; k++)
>                 b[k] = false;        
>         }
>         if(Im)
>             printf("Impossible\n");
>         else
>         {  
>             for(k=0; k<len-1; k++)
>                 printf("%I64d ",a[k]);
>             printf("%I64d\n",a[len-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