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

咋错了?错哭了!

Posted by acm_bug at 2006-10-03 11:55:58 on Problem 2549
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
long a[1001];
int main()
{
    int n;
    while(cin>>n&&n)
    {
                 for(int i=0;i<n;++i)
                 cin>>a[i];
                 sort(a,a+n);
                 bool t=0;
                 for(int i=n-1;i>=3;--i)
                 {
                    for(int j=i-1;j>=2;--j)
                    {
                       if((a[i]-a[j])<a[0])continue;
                       for(int k=0;k<=j-2;++k)
                       {
                          
                          if(!binary_search(a+k+1,a+j,(a[i]-a[j]-a[k])))continue;
                          cout<<a[i]<<endl;t=1;
                       }
                       if(t)break;
                       
                    }
                    if(t)break;
                 }
                 if(!t)cout<<"no solution"<<endl;
                 
    
    }
    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