L1-019. 谁先倒
来源:互联网 发布:济宁淘宝店卖什么的多 编辑:程序博客网 时间:2024/06/05 03:15
L1-019. 谁先倒
时间限制
400 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
陈越
划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就输了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。
下面给出甲、乙两人的酒量(最多能喝多少杯不倒)和划拳记录,请你判断两个人谁先倒。
输入格式:
输入第一行先后给出甲、乙两人的酒量(不超过100的非负整数),以空格分隔。下一行给出一个正整数N(<=100),随后N行,每行给出一轮划拳的记录,格式为:
甲喊 甲划 乙喊 乙划
其中“喊”是喊出的数字,“划”是划出的数字,均为不超过100的正整数(两只手一起划)。
输出格式:
在第一行中输出先倒下的那个人:A代表甲,B代表乙。第二行中输出没倒的那个人喝了多少杯。题目保证有一个人倒下。注意程序处理到有人倒下就终止,后面的数据不必处理。
输入样例:1 168 10 9 125 10 5 103 8 5 1212 18 1 134 16 12 1515 1 1 16输出样例:
A1
#include <iostream>using namespace std;int fun(int a1,int a2,int b1,int b2);int main(){ int m,n; cin>>m>>n; int t; cin>>t; int a1,a2,b1,b2; int A1=0,B1=0; for(int i=0;i<t;i++){ cin>>a1>>a2>>b1>>b2; int temp = fun(a1,a2,b1,b2); if(temp==1){ m--; ++A1; if(m<0){ cout<<"A"<<endl; cout<<B1<<endl; break; } }else if(temp==-1){ n--; ++B1; if(n<0){ cout<<"B"<<endl; cout<<A1<<endl; break; } }else if(temp==2){ continue; } else continue; } return 0;}int fun(int a1,int a2,int b1,int b2){ if(a2==(a1+b1)&&b2!=(a1+b1)){ return 1; } else if(b2==(a1+b1)&&a2!=(a1+b1)){ return -1; } else if(b2==(a1+b1)&& a2==(a1+b1)){ return 2; }else return 0;}
0 0
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒 java
- L1-019. 谁先倒
- PAT L1-019. 谁先倒
- L1-019. 谁先倒
- PAT L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- L1-019. 谁先倒
- 天梯赛 L1-019. 谁先倒
- sublime中pre代码片段的设置
- java的blockingqueue
- Java 选择排序
- 【DP入门】石子合并(一)
- Java基于TCP实现服务器和多客户端之间的通信
- L1-019. 谁先倒
- 多态+菱形虚拟继承(下)
- jQuery( )方法的构建原理
- 科锐课堂笔记:2017/3/2 函数调用约定
- android开发错误学习笔记
- android开源框架-----Picasso框架的使用
- L1-020. 帅到没朋友
- Python版本管理:pyenv和pyenv-virtualenv(MAC、Linux)、virtualenv和virtualenvwrapper(windows)
- leetcode150. Evaluate Reverse Polish Notation