1046. 划拳(15)
来源:互联网 发布:c语言闰年判断 编辑:程序博客网 时间:2024/05/22 00:32
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
#include<iostream>#include<algorithm>#include<iomanip>#include<cstring>#include<vector>#include<stdio.h>#include<math.h>#include<string>#include<sstream>using namespace std;int main(){ int n; cin>>n; int a,b,c,d;int sum=0; int cnta=0;int cntb=0; for(int i=0;i<n;i++) { cin>>a>>b>>c>>d; sum=a+c; if(b==sum && d!=sum)cntb++; if(b!=sum && d==sum)cnta++; } cout<<cnta<<" "<<cntb; return 0;}
阅读全文
0 0
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 【PAT】1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 1046. 划拳(15)
- 源码 Dialog 的 window 创建过程
- android自定义调节器控件 —— RegulatorView
- hadoop参数-core-site.xml
- Java设计模式之结构型模式-装饰器模式(Decorator)
- java序列化与反序列化
- 1046. 划拳(15)
- Array对象的方法实现(4)----Array.prototype.findIndex和Array.prototype.forEach(实现常规参数的功能)
- shell输入/输出重定向
- Cygwin粘贴复制
- hadoop端口
- xml的layout_weight计算原理
- Mybatis查看完整SQL及执行性能
- LNMP部署网站 访问php文件 404
- 19.Redis Cluster