当前位置:网站首页>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;
} 边栏推荐
- js实现查看一个数组对象中是否包含另一个数组对象中的值
- Global and Chinese market of basketball uniforms 2022-2028: Research Report on technology, participants, trends, market size and share
- Reconfiguration of nebula integration testing framework based on BDD theory (Part 2)
- Event related | reveal how Ti-One's support ability for large-scale events is developed
- Explain the input attribute in PHP (hide the read-only restriction)
- 希尔伯特-黄变换
- 《canvas》之第4章 线条操作
- RDD的执行原理
- Tuple remarks
- opencvsharp二值图像反色
猜你喜欢

What kind of experience is it when the Institute earns 20000 yuan a month!

Basics of reptile B1 - scrapy (learning notes of station B)

『C语言』系统日期&时间

Moonwell Artemis现已上线Moonbeam Network

光照使用的简单总结

GPU is not used when the code is running

The two most frequently asked locks in the interview

本地备份和还原 SQL Server 数据库

保留一位小数和保留两位小数

【Django中运行scrapy框架,并将数据存入数据库】
随机推荐
Random number remarks
第 2 篇:繪制一個窗口
光照使用的简单总结
BOM笔记
Any remarks
timer使用备注
atguigu----15-内置指令
What is the lifecycle of automated testing?
How to realize multi protocol video capture and output in video surveillance system?
鸿蒙os开发三
Super fast reading in OI
Global and Chinese market of Earl Grey tea 2022-2028: Research Report on technology, participants, trends, market size and share
Phonics
交友相亲类软件是如何割你韭菜的
自动化测试的生命周期是什么?
关于h5页面苹果手机使用fixed定位tabbar最底部时遮挡内容问题
线程的阻塞问题
报错“Computation failed in `stat_summary_hex()`”
The seminar on "global IPv6 development and outlook 2020-2021" was held in Beijing
Commandes de console communes UE