当前位置:网站首页>1071 Small Gamble (15 points)
1071 Small Gamble (15 points)
2022-08-11 07:48:00 【dumb bit】
题目要求:
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int k = sc.nextInt();
sc.nextLine();
for (int i = 0; i < k; i++) {
String[] s = sc.nextLine().split(" ");
if (t < Integer.valueOf(s[2])){
System.out.println("Not enough tokens. Total = "+ t +".");
}else{
int flag = Integer.valueOf(s[0]) < Integer.valueOf(s[3]) ? 1 : 0;
if (flag == Integer.valueOf(s[1])){
t += Integer.valueOf(s[2]);
System.out.println("Win "+ Integer.valueOf(s[2]) +"! Total = "+ t +".");
} else {
t -= Integer.valueOf(s[2]);
System.out.println("Lose "+ Integer.valueOf(s[2]) +". Total = "+ t +".");
}
}
if (t == 0){
System.out.println("Game Over.");
break;
}
}
}
}
结果:
边栏推荐
猜你喜欢
随机推荐
When MySQL uses GROUP BY to group the query, the SELECT query field contains non-grouping fields
TF中的四则运算
TF通过feature与label生成(特征,标签)集合,tf.data.Dataset.from_tensor_slices
pytorch,numpy两种方法实现nms类间+类内
MindManager2022全新正式免费思维导图更新
C语言每日一练——Day02:求最小公倍数(3种方法)
What are the things that should be planned from the beginning when developing a project with Unity?How to avoid a huge pit in the later stage?
Item 2 - Annual Income Judgment
Redis source code: how to view the Redis source code, the order of viewing the Redis source code, the sequence of the source code from the external data structure of Redis to the internal data structu
1091 N-自守数 (15 分)
1101 How many times B is A (15 points)
囍楽云任务源码
2022年中国软饮料市场洞察
matplotlib
3.2-分类-Logistic回归
【LeetCode每日一题】——844.比较含退格的字符串
Discourse's Close Topic and Reopen Topic
NTT的Another Me技术助力创造歌舞伎演员中村狮童的数字孪生体,将在 “Cho Kabuki 2022 Powered by NTT”舞台剧中首次亮相
STM32CUBEIDE(11)----输出PWM及修改PWM频率与占空比
How do you optimize the performance of your Unity project?