-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1192PaulasMathematicGame.java
More file actions
40 lines (34 loc) · 1.1 KB
/
URI1192PaulasMathematicGame.java
File metadata and controls
40 lines (34 loc) · 1.1 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1192">Paula's Mathematic Game</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1192PaulasMathematicGame {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int N = readInt(), a, b;
char[] s;
while (N-- > 0) {
s = in.readLine().toCharArray();
a = Character.getNumericValue(s[0]);
b = Character.getNumericValue(s[2]);
if (a == b) {
out.println(a * b);
} else if (Character.isLowerCase(s[1])) {
out.println(a + b);
} else {
out.println(b - a);
}
}
out.close();
}
private static int readInt() throws IOException {
return Integer.parseInt(in.readLine());
}
}