PAT (Basic Level) Practise (中文) 1046. 划拳(15)
来源:互联网 发布:mac pro 魔兽世界 编辑:程序博客网 时间:2024/05/22 00:15
1046. 划拳(15)
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。
下面给出甲、乙两人的划拳记录,请你统计他们最后分别喝了多少杯酒。
输入格式:
输入第一行先给出一个正整数N(<=100),随后N行,每行给出一轮划拳的记录,格式为:
甲喊 甲划 乙喊 乙划
其中“喊”是喊出的数字,“划”是划出的数字,均为不超过100的正整数(两只手一起划)。
输出格式:
在一行中先后输出甲、乙两人喝酒的杯数,其间以一个空格分隔。
输入样例:58 10 9 125 10 5 103 8 5 1212 18 1 134 16 12 15输出样例:
1 2
/* * 啊哈哈,这对喝酒的人太简单了 * 会喝酒的人题意分分钟理解 * 需要注意的一点是, * 两个人喊的数字如果一样的话双方都不需要喝酒 */import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int a=0; int b=0; for (int i = 0; i < n; i++) { int temp[]=new int[4]; for (int j = 0; j < temp.length; j++) { temp[j]=input.nextInt(); } if (temp[1]!=temp[3]) { int sum=temp[0]+temp[2]; if (sum == temp[1]) { b++; } if (sum == temp[3]) { a++; } } } System.out.println(a+" "+b); }}
阅读全文
0 0
- PAT (Basic Level) Practise (中文)1046. 划拳(15)
- PAT (Basic Level) Practise (中文) 1046. 划拳(15)
- PAT BASIC LEVEL 1046. 划拳(15)
- PAT (Basic Level)1046. 划拳
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)1001
- PAT (Basic Level) Practise (中文)1002
- PAT (Basic Level) Practise (中文) 1007
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)-1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文)1031. 查验身份证(15)
- PAT (Basic Level) Practise (中文) 1021. 个位数统计 (15)
- PAT (Basic Level) Practise (中文) 1031. 查验身份证(15)
- PAT (Basic Level) Practise (中文) 1051. 复数乘法 (15)
- Python 构造二叉搜索树
- 林纳斯·托瓦兹(Linus Torvalds)为什么被称作大神?
- codeforces 706A Beru-taxi
- 关于预答辩研究生汇报内容及方式的几点要求
- <剑指offer>javascript解法(1-65)
- PAT (Basic Level) Practise (中文) 1046. 划拳(15)
- Lua_ Lua结合BundleManager实现网络热更新_023
- C语言里的符号重载《C专家编程》
- 框架常见面试题
- 前端框架:Angular React 和 Vue的比较
- TensorFlow学习笔记(二)把数字标签转化成onehot标签
- javascript表单验证
- Linux 下安装 JDK
- 笨方法学python 习题16