Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0da1244

Browse files
author
Rafael Cunha de Almeida
committedDec 7, 2014
C# implementation
1 parent e1e808c commit 0da1244

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 

‎Nsteps.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
public class Nsteps {
4+
public static long CoordsToNumber(long x, long y) {
5+
if (y != (x-2) && y != x) {
6+
return -1;
7+
}
8+
if (x % 2 == 0) {
9+
return x + y;
10+
} else {
11+
return x + y - 1;
12+
}
13+
}
14+
15+
public static void Main() {
16+
int lines = Convert.ToInt32(Console.ReadLine());
17+
while (lines-- > 0) {
18+
string[] tuple = Console.ReadLine().Split(' ');
19+
long number = CoordsToNumber(Convert.ToInt64(tuple[0]), Convert.ToInt64(tuple[1]));
20+
if (number < 0) {
21+
Console.WriteLine("No Number");
22+
} else {
23+
Console.WriteLine(number);
24+
}
25+
}
26+
}
27+
}

‎nsteps.test

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
4 2
3+
6 6
4+
3 4

0 commit comments

Comments
 (0)
Please sign in to comment.