-
Notifications
You must be signed in to change notification settings - Fork 3
/
B.cpp
203 lines (156 loc) · 5.02 KB
/
B.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include<complex>
//#include <bits/stdc++.h>
using namespace std;
#define HI printf("HI\n")
#define sf scanf
#define pf printf
#define sf1(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
#define sf1ll(a) scanf("%lld",&a)
#define sf2ll(a,b) scanf("%lld %lld",&a,&b)
#define sf3ll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sf4ll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define pb push_back
#define ppb pop_back
#define ppf push_front
#define popf pop_front
#define ll long long int
#define ui unsigned int
#define ull unsigned long long
#define fs first
#define sc second
#define clr( a, b ) memset((a),b,sizeof(a))
#define jora pair<int, int>
#define jora_d pair<double, double>
#define jora_ll pair<long long int, long long int>
#define mp make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI acos(-1.0)
#define ps pf("PASS\n")
#define popc(a) (__builtin_popcount(a))
template<class T1> void deb(T1 e1) {
cout<<e1<<endl;
}
template<class T1,class T2> void deb(T1 e1,T2 e2) {
cout<<e1<<" "<<e2<<endl;
}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3) {
cout<<e1<<" "<<e2<<" "<<e3<<endl;
}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4) {
cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<endl;
}
template<class T1,class T2,class T3,class T4,class T5> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5) {
cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<endl;
}
template<class T1,class T2,class T3,class T4,class T5,class T6> void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6) {
cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<" "<<e5<<" "<<e6<<endl;
}
/// <--------------------------- For Bitmasking -------------------------------->
//int on( int n, int pos ){
// return n = n|( 1<<pos );
//}
//bool check( int n, int pos ){
// return (bool)( n&( 1<<pos ) );
//}
//int off( int n, int pos ){
// return n = n&~( 1<<pos );
//}
//int toggle( int n, int pos ){
// return n = n^(1<<pos);
//}
//int count_bit( int n ){
// return __builtin_popcount( n );
//}
/// <--------------------------- End of Bitmasking -------------------------------->
/// <--------------------------- For B - Base Number System ----------------------------------->
//int base;
//int pw[10];
//void calPow(int b){
// base = b;
// pw[0] = 1;
// for( int i = 1; i<10; i++ ){
// pw[i] = pw[i-1]*base;
// }
//}
//int getV(int mask, int pos){
// mask /= pw[pos];
// return ( mask%base );
//}
//int setV(int mask, int v, int pos){
// int rem = mask%pw[pos];
// mask /= pw[pos+1];
// mask = ( mask*base ) + v;
// mask = ( mask*pw[pos] ) + rem;
// return mask;
//}
/// <--------------------------- End B - Base Number System ----------------------------------->
// moves
//int dx[]= {0,0,1,-1};/*4 side move*/
//int dy[]= {-1,1,0,0};/*4 side move*/
//int dx[]= {1,1,0,-1,-1,-1,0,1};/*8 side move*/
//int dy[]= {0,1,1,1,0,-1,-1,-1};/*8 side move*/
int dx[]={1,1,2,2,-1,-1,-2,-2};/*night move*/
int dy[]={2,-2,1,-1,2,-2,1,-1};/*night move*/
//double Expo(double n, int p) {
// if (p == 0)return 1;
// double x = Expo(n, p >> 1);
// x = (x * x);
// return ((p & 1) ? (x * n) : x);
//}
//ll bigmod(ll a,ll b,ll m){if(b == 0) return 1%m;ll x = bigmod(a,b/2,m);x = (x * x) % m;if(b % 2 == 1) x = (x * a) % m;return x;}
//ll BigMod(ll B,ll P,ll M){ ll R=1%M; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;} /// (B^P)%M
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MXN 50
#define MXE
#define MXQ
#define SZE
#define MOD
#define EPS
#define INF 1000000000
#define MX 200
#define inf 100000000
int main() {
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
//ios_base::sync_with_stdio(0);
// freopen("input.txt", "r", stdin);
// pf("Welcome to ACM ICPC Dhaka Regional Online Preliminary Contest, 2018\n");
int ts,a,b,casio=1;
scanf("%d",&ts);
while(ts--)
{
int cnt=0;
scanf("%d%d",&a,&b);
for(int i=0;i<8;i++)
{
int c=dx[i]+a;
int d=dy[i]+b;
if(c<1||c>8||d<1||d>8)continue;
cnt++;
}
printf("Case %d: %d\n",casio++,cnt);
}
return 0;
}