-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dylan.java
37 lines (36 loc) · 1.18 KB
/
Dylan.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
import java.io.*;
import java.util.*;
public class Dylan {
static BufferedReader br;
static PrintWriter out;
static StringTokenizer st = new StringTokenizer("");
static int T = 1;
public static void main(String[] args) throws IOException {
// br = new BufferedReader(new InputStreamReader(System.in));
br = new BufferedReader(new FileReader("dylan.dat"));
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
T = nexti();
for (int tt = 1; tt <= T; tt++) {
long k = nextl(), r = nextl(), c = nextl();
--r; --c;
out.println(2L * k * r + (c < k ? 2 * (k - 1L - c) : 1 + 2L * (c - k)));
}
br.close(); out.close();
}
static String next() throws IOException{
while(!st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
return st.nextToken();
}
static int nexti() throws IOException {
return Integer.parseInt(next());
}
static long nextl() throws IOException {
return Long.parseLong(next());
}
static double nextd() throws IOException {
return Double.parseDouble(next());
}
static double round(double d) {
return Math.round(d * 100.0) / 100.0;
}
}