-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDSA01026.cpp
More file actions
59 lines (57 loc) · 872 Bytes
/
Copy pathDSA01026.cpp
File metadata and controls
59 lines (57 loc) · 872 Bytes
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
#include<bits/stdc++.h>
using namespace std;
bool check(int a[], int n)
{
if(a[1] != 8 || a[n] != 6)
return 0;
for(int i = 2; i<=n; i++)
{
if(a[i] == 8 && a[i-1] == 8)
return 0;
}
int b[n+5] = {};
int ans = 0;
for(int i = 1; i<=n-3; i++)
{
if(a[i] == 6 && a[i+1] == 6 && a[i+2] == 6 && a[i+3] == 6)
{
return 0;
}
}
return 1;
}
int main()
{
int n;
cin >> n;
int a[n+5] = {};
for(int i = 1; i<=n; i++)
{
a[i] = 6;
}
while(1)
{
if(check(a, n))
{
for(int i = 1; i<=n; i++)
{
cout << a[i];
}
cout << endl;
}
int l = n;
while(a[l] == 8 && l)
{
a[l] = 6;
l--;
}
if(l==0)
{
break;
}
else
{
a[l] = 8;
}
}
}