-
Notifications
You must be signed in to change notification settings - Fork 0
/
nsteps.cpp
48 lines (44 loc) · 826 Bytes
/
nsteps.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
#include <iostream>
#include <algorithm>
#include <bitset>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
map < pair<int, int>, int > pointSet;
void create_map() {
for (int i = 0; i <= 20000; ++i) {
int x = 2*(i/4);
int y = 2*(i/4);
if (i%4 == 1) {
x += 1;
y += 1;
}
if (i%4 == 2)
x += 2;
if (i%4 == 3) {
x += 3;
y += 1;
}
pointSet[make_pair(x, y)] = i;
}
}
int main() {
freopen("input.txt", "r", stdin);
int test_cases, x, y;
create_map();
cin >> test_cases;
while (test_cases--) {
cin >> x >> y;
if (pointSet[make_pair(x, y)] != 0 || (x == 0 && y == 0))
cout << pointSet[make_pair(x, y)] << endl;
else cout << "No Number" << endl;
}
return 0;
}