-
Notifications
You must be signed in to change notification settings - Fork 0
/
11063_B2sequence.cpp
54 lines (46 loc) · 1007 Bytes
/
11063_B2sequence.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
#include<iostream>
#include<map>
using namespace std;
int main()
{
long long int arr[110],N,i,j,Case=1,flag;
map<int,int>m;
while(cin>>N)
{
m.clear();
flag=1;
for(i=0;i<N;i++)
{
cin>>arr[i];
}
for(i=0;i<N-1;i++)
{
if(arr[i]<1||arr[i]>=arr[i+1])
{
flag=0;
i=N;
}
}
if(flag)
{
for(i=0;i<N;i++)
{
for(j=i;j<N;j++)
{
if(m[arr[i]+arr[j]]==1)
{
flag=0;
i=j=N;
}
else
m[arr[i]+arr[j]]=1;
}
}
}
if(flag)
cout<<"Case #"<<Case++<<": It is a B2-Sequence."<<endl<<endl;
else
cout<<"Case #"<<Case++<<": It is not a B2-Sequence."<<endl<<endl;
}
return 0;
}