-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bishops.java
39 lines (33 loc) · 954 Bytes
/
Bishops.java
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
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.*;
import java.util.stream.*;
import java.io.*;
import java.math.*;
import java.text.*;
/*
* @author Theodoric Keith Lim
*/
class Bishops {
public static void main(String[] args) {
// https://en.wikibooks.org/wiki/Chess/Puzzles/Placement/14_Bishops/Solution#:~:text=Since%2014%20bishops%20is%20possible,no%20two%20attack%20each%20other.v
// placement is one straight line one each side, take away bishops at one side's rook ends.
// 0 0
// 1 1
// 2 2
// 3 4
// 4 6
// 5 8
// 6 10
// 7 12
// 8 14
Kattio sc = new Kattio(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasMoreTokens()) {
int n = sc.getInt();
out.println(n == 0 || n == 1 ? n : 2 * n - 2);
}
out.close();
sc.close();
}
}