-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXhaeneung.java
More file actions
63 lines (57 loc) · 2.07 KB
/
Xhaeneung.java
File metadata and controls
63 lines (57 loc) · 2.07 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main{
private static int i1;
private static int i2;
private static String operator;
private static int answer;
private static String[] num = {"zero","one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int c = Integer.parseInt(br.readLine());
while(c-- >0){
StringTokenizer st = new StringTokenizer(br.readLine());
i1 = strToInt(st.nextToken());
operator = st.nextToken();
i2 = strToInt(st.nextToken());
st.nextToken();
answer = strToInt(answerIn(st.nextToken()));
// System.out.println(i1+ operator + i2 +"="+answer);
System.out.println(correct());
}
}
// string to int
public static int strToInt(String s){
for(int i = 0; i<num.length;i++){
// System.out.println(s +", " + num[i] + ", " + i);
if(s.equals(num[i])) return i;
}return -999999;
}
public static String answerIn(String s){
for( String s1 : num){
String s2 = s1;
// System.out.println(s1 + s);
for(int i = 0; i<s.length();i++){
for(int j = 0; j<s1.length();j++){
if(s.charAt(i)==s1.charAt(j)){
s1=s1.replace(String.valueOf(s1.charAt(j)),"");
break;
}
}
}
if(s1.isEmpty())return s2;
}
return "false";
}
public static String correct(){
switch(operator){
case "+" : return (i1+i2==answer?"Yes":"No");
case "-" : return (i1-i2==answer?"Yes":"No");
case "*" : return (i1*i2==answer?"Yes":"No");
case "/" : return (i1/i2==answer?"Yes":"No");
}
return "No";
}
}