-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zju 1101.txt
50 lines (49 loc) · 1.1 KB
/
Zju 1101.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int D[1010];
int i,j,k,m,n;
while(scanf("%d",&n),n)
{
for(i=0;i<n;++i)
scanf("%d",&D[i]);
sort(D,D+n);
bool T=false;
int q,p,tmp1,tmp2;
for(i=n-1;i>=0;--i)
{
for(j=n-1;j>=0;--j)
{
if(j==i) continue;
tmp1=D[i]-D[j];
p=0;q=n-1;
tmp2=D[p]+D[q];
while(p<q)
{
if(tmp2>tmp1)
--q;
else if(tmp2<tmp1)
++p;
else
{
if(p==i||p==j) ++p;
else if(q==i||q==j) --q;
else
{
printf("%d\n",D[i]);
T=true;
goto out;
}
}
tmp2=D[p]+D[q];
}
}
}
out:
if(T==false) printf("no solution\n");
}
return 0;
}