-
Notifications
You must be signed in to change notification settings - Fork 0
/
11063.cpp
executable file
·107 lines (82 loc) · 1.38 KB
/
11063.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include<stdio.h>
#include<stdlib.h>
#define sz 100009
int f=0;
int comp(void const *A, void const *B)
{
long *a = (long*)A;
long *b = (long*)B;
if(*a>*b)
return 1;
if(*a<*b)
return -1;
else
{ f=1;
return 0;
}
}
void main()
{
long n,cases=1,i,j,a[105],x,old,p;
int flag;
long sum[sz];
while(scanf("%ld",&n)==1)
{
old = 0;
flag=0;
f=0;
for(i=0;i<n;i++)
{
scanf("%ld",&x);
if(x>old)
{
old=x;
}
else
flag=1;
a[i]=x;
}
if(flag==1)
printf("Case #%ld: It is not a B2-Sequence.\n\n",cases++);
else
{
p=0;
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
sum[p++] = a[i]+a[j];
}
}
//for(i=0;i<p;i++)
// printf("%ld ",sum[i]);
//printf("\n");
qsort(sum,p,sizeof(sum[0]),comp);
/*
x=sum[0];
flag=0;
for(i=1;i<p;i++)
{
if(x==sum[i])
{
flag=1;
break;
}
else
x = sum[i];
}
for(i=0;i<p;i++)
printf("%ld ",sum[i]);
printf("\n");
if(flag==1)
printf("Case #%ld: It is not a B2-Sequence.\n\n",cases++);
else
printf("Case #%ld: It is a B2-Sequence.\n\n",cases++);
*/
if(f==1)
printf("Case #%ld: It is not a B2-Sequence.\n\n",cases++);
else
printf("Case #%ld: It is a B2-Sequence.\n\n",cases++);
}
}
}