-
Notifications
You must be signed in to change notification settings - Fork 1
/
E.cpp
63 lines (58 loc) · 989 Bytes
/
E.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
#include<bits/stdc++.h>
using namespace std;
int check[100][100];
void fn(int x,int y,int n,int a)
{
if(n<0)
return;
printf("%c%d\n",'a'+x-1,y);
if(y==7&&n==3&&x==7){
printf("g8\nf8\nh8\n");
return;
}
else if(n==2&&x==8){
printf("h7\nh8\n");
return;
}
if(y<8&&n==2){
fn(x,8,n-1,a);
return;
}
if(y==8&&n==1){
fn(8,8,n-1,a);
return;
}
if(y==8){
if(x==6){
fn(x+1,y,n-1,-2);
}
else{
fn(x+a,y,n-1,a);
}
return;
}
else{
int z=x+a;
if(z>8){
if(x==8)
z=7;
else
z=8;
fn(z,y,n-1,-2);
}
else if(z<=0){
fn(x,y+1,n-1,2);
}
else{
fn(x+a,y,n-1,a);
}
return;
}
}
int main()
{
int n,m,i,j,k,a,b,c,x,y,z;
cin>>n;
fn(1,1,n,2);
return 0;
}