当前位置:网站首页>L1-019 who goes first (15 points)
L1-019 who goes first (15 points)
2022-06-24 07:49:00 【Code Knight】
Boxing is an interesting part of the ancient Chinese wine culture . The method of two people on the wine table is : Shout out a number from each mouth , Draw a number with your hand . If someone's number is exactly equal to the sum of the two Numbers , Who is lost , The loser gets a glass of wine . Either a win or a loss goes on to the next round , Until the only winner comes along .
So let's give you a 、 B how much for two ( How many cups can you drink at most ) And punching records , Please judge which of the two should go first .
Input format :
The first line of input gives us a 、 B how much for two ( No more than 100 Non-negative integer ), Space off . The next line gives a positive integer N(≤100), And then N That's ok , Each line gives a record of one stroke , The format is :
A shout A stroke Ethyl shout B row
among shout It's the number called out , draw It's a number , No more than 100 The positive integer ( Row with both hands ).
Output format :
Output the first person to fall on the first line :A On behalf of a ,B On behalf of the b . The second line shows how many drinks the person who didn't pour had . They guarantee that one person will fall . Note that the program terminates when someone drops , You don't have to deal with the rest of the data .
sample input :
1 1
6
8 10 9 12
5 10 5 10
3 8 5 12
12 18 1 13
4 16 12 15
15 1 1 16
sample output :
A
1Ideas :
① data structure : Structure
② Algorithm : Compare
Source code :
#include<iostream>
using namespace std;
struct A
{
int max;
int han;
int hua;
int d;
}a;
struct B
{
int max;
int han;
int hua;
int d;
}b;
int ans_r;
char ans_c;
int key=0;//key=0, There is no answer
int main()
{
cin>>a.max>>b.max;
int round;
cin>>round;
a.d=0;b.d=0;
for(int i=0;i<round;i++)
{
cin>>a.han>>a.hua>>b.han>>b.hua;
if(a.hua==b.han+a.han)
{
a.d++;
b.hua==b.han+a.han;
if(a.hua==b.hua)
a.d--;
}
if(b.hua==b.han+a.han)
{
b.d++;
a.hua==b.han+a.han;
if(a.hua==b.hua)
b.d--;
}
if(a.d>a.max&&key==0)
{
ans_c='A';
ans_r=b.d;
key=1;
}
if(b.d>b.max&&key==0)
{
ans_c='B';
ans_r=a.d;
key=1;
}
}
if(key==1)
{
cout<<ans_c<<endl<<ans_r;
}
return 0;
} 边栏推荐
- Bit operation
- 10. Tencent cloud IOT device side learning - firmware upgrade
- Overview of C program operation mechanism
- Reconfiguration of nebula integration testing framework based on BDD theory (Part 2)
- 解决错误: LNK2019 无法解析的外部符号
- Climbing 10000 NASA pictures about Mars exploration, I found a secret
- How to realize multi protocol video capture and output in video surveillance system?
- 【Django中运行scrapy框架,并将数据存入数据库】
- Thread blocking
- 『C语言』系统日期&时间
猜你喜欢

Hilbert Huang Transform

Baidu map, coordinate inversion, picking coordinate position

2022年PMP项目管理考试敏捷知识点(1)

ImportError: cannot import name ‘process_pdf‘ from ‘pdfminer.pdfinterp‘错误完全解决

【008】表格数据逐行筛选,跳出for循环及跳过本次循环思路_#VBA

第 2 篇:绘制一个窗口

爬虫基础B1——Scrapy(B站学习笔记)

exness:鲍威尔坚持抗通胀承诺,指出衰退是可能的

【Django中运行scrapy框架,并将数据存入数据库】

Basics of reptile B1 - scrapy (learning notes of station B)
随机推荐
Common array encapsulation
语料库数据处理个案实例(句子检索相关个案)
《canvas》之第1章 canvas概述
后疫情时代下,家庭服务机器人行业才刚启航
Explain the input attribute in PHP (hide the read-only restriction)
Win10 build webservice
Global and Chinese market of bed former 2022-2028: Research Report on technology, participants, trends, market size and share
Thread blocking
《canvas》之第2章 直线图形
UTC、GMT、CST
Oracle-高级SQL限定查询
Smart pointer remarks
Resolution error: LNK2019 unresolved external symbol
希尔伯特-黄变换
Random number remarks
Part 2: drawing a window
LeetCode 207:课程表(拓扑排序判断是否成环)
Chapitre 2: dessiner une fenêtre
opencvsharp二值图像反色
10. Tencent cloud IOT device side learning - firmware upgrade