-
Notifications
You must be signed in to change notification settings - Fork 0
/
255.cpp
executable file
·45 lines (35 loc) · 968 Bytes
/
255.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
#include <stdio.h>
int main ()
{
int k, q, qm,r, rm, rk, first, last ;
while ( scanf ( "%d %d %d", &k, &q, &qm ) == 3 )
{
if ( k == q ) printf ( "Illegal state\n" ) ;
else
{
r = q % 8 ;
rm = qm % 8 ;
rk = k % 8 ;
first = q - r ;
last = first + 7 ;
if ( qm == q || k == qm || ( r != rm && ( ( qm < first || qm > last)
|| ( ( qm < k && k < q ) || ( qm > k && k > q ) ) ) || ( ( rm == r
&& r == rk ) && ( ( qm < k && k < q ) || ( qm > k && k > q ) ) ) ) )
printf ( "Illegal move\n" ) ;
else
{
if ( ( qm == k + 1 && rk != 7 ) || ( qm == k - 1 && rk != 0 )
|| ( qm == k - 8 ) || ( qm == k + 8 ) )
printf ( "Move not allowed\n" ) ;
else
{
if ( ( k == 0 && qm == 9 ) || ( k == 7 && qm == 14 )
|| ( k == 56 && qm == 49 ) || ( k == 63 && qm == 54 ) )
printf ( "Stop\n" ) ;
else printf ( "Continue\n" ) ;
}
}
}
}
return 0;
}