输入样例 1:
100 4
8 0 100 2
3 1 50 1
5 1 200 6
7 0 200 8
输出样例 1:
Win 100! Total = 200.
Lose 50. Total = 150.
Not enough tokens. Total = 150.
Not enough tokens. Total = 150.
输入样例 2:
100 4
8 0 100 2
3 1 200 1
5 1 200 6
7 0 200 8
输出样例 2:
Win 100! Total = 200.
Lose 200. Total = 0.
Game Over.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Main {
static int T;
static String[] temp;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] a = br.readLine().split(" ");
T = Integer.parseInt(a[0]);
int C = Integer.parseInt(a[1]);
boolean symbol = false;
while(C>0) {
temp = br.readLine().split(" ");
if(Integer.parseInt(temp[2])>T) {
System.out.println("Not enough tokens. Total = "+T+".");
}else {
if(Integer.parseInt(temp[0]) > Integer.parseInt(temp[3])
&& Integer.parseInt(temp[1])==0) {
Win();
}
else if(Integer.parseInt(temp[0]) < Integer.parseInt(temp[3])
&& Integer.parseInt(temp[1])==1) {
Win();
}
else if(Integer.parseInt(temp[0]) < Integer.parseInt(temp[3])
&& Integer.parseInt(temp[1])==0) {
Lose();
}
else if(Integer.parseInt(temp[0]) > Integer.parseInt(temp[3])
&& Integer.parseInt(temp[1])==1) {
Lose();
}
if(T<=0) {
System.out.println("Game Over.");
break;
}
C--;
}
}
if(symbol) {
for (int i = 1; i < C; i++) {
System.out.println("Not enough tokens. Total = "+T+".");
}
}
}
public static void Win() {
T+=Integer.parseInt(temp[2]);
System.out.println("Win "+temp[2]+"! Total = "+T+".");
}
public static void Lose() {
T-=Integer.parseInt(temp[2]);
System.out.println("Lose "+temp[2]+". Total = "+T+".");
}
}