| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:咋错了?错哭了!In Reply To:咋错了?错哭了! Posted by:acm_bug at 2006-10-03 11:55:58 > #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;break;//加个这个忘记了,还是不行
> }
> if(t)break;
>
> }
> if(t)break;
> }
> if(!t)cout<<"no solution"<<endl;
>
>
> }
> return 0;
> }
>
>
>
>
>
>
>
>
>
>
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator