当前位置:网站首页>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;
}
}
}
}
结果:
边栏推荐
猜你喜欢
机器学习总结(二)
我的创作纪念日丨感恩这365天来有你相伴,不忘初心,各自精彩
1002 写出这个数 (20 分)
技能在赛题解析:交换机防环路设置
Pico neo3在Unity中的交互操作
PIXHAWK飞控使用RTK
项目1-PM2.5预测
【LeetCode每日一题】——844.比较含退格的字符串
Redis源码-String:Redis String命令、Redis String存储原理、Redis字符串三种编码类型、Redis String SDS源码解析、Redis String应用场景
Resolved EROR 1064 (42000): You have an error in. your SOL syntax. check the manual that corresponds to yo
随机推荐
2022-08-10 Group 4 Self-cultivation class study notes (every day)
Activity的四种状态
prometheus学习4Grafana监控mysql&blackbox了解
【Pytorch】nn.PixelShuffle
项目2-年收入判断
C语言每日一练——Day02:求最小公倍数(3种方法)
SQL sliding window
How do you optimize the performance of your Unity project?
Tf中的平方,多次方,开方计算
那些事情是用Unity开发项目应该一开始规划好的?如何避免后期酿成巨坑?
【软件测试】(北京)字节跳动科技有限公司二面笔试题
公牛10-11德里克·罗斯最强赛季记录
6月各手机银行活跃用户较快增长,创半年新高
oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?
Trill keyword search goods - API
数仓开发知识总结
TF中的四则运算
Unity3D 学习路线?
tf.cast(), reduce_min(), reduce_max()
基于FPGA的FIR滤波器的实现(4)— 串行结构FIR滤波器的FPGA代码实现