当前位置:网站首页>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;
} 边栏推荐
猜你喜欢

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

Hilbert Huang Transform

光照使用的简单总结

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

LeetCode 207:课程表(拓扑排序判断是否成环)

Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its

图形技术之坐标转换

Hongmeng OS development III

First acquaintance with JUC - day01

exness:鲍威尔坚持抗通胀承诺,指出衰退是可能的
随机推荐
New ways to play web security [6] preventing repeated use of graphic verification codes
Reppoints: Microsoft skillfully uses deformation convolution to generate point sets for target detection, full of creativity | iccv 2019
解决错误: LNK2019 无法解析的外部符号
Thread support
UE common console commands
RDD的执行原理
POM configuration provided and test
『C语言』系统日期&时间
位运算
Cloud development who is the source code of undercover applet
C# Lambda
线程注意事项
tuple(元组)备注
Q & A on cloud development cloudbase hot issues of "Huage youyue phase I"
Teach you how to use the reflect package to parse the structure of go - step 2: structure member traversal
Thread blocking
报错“Computation failed in `stat_summary_hex()`”
保留一位小数和保留两位小数
The startup mode of cloudbase init is \Cloudbase init has hidden dangers
Global and Chinese markets for maritime transport of perishable goods 2022-2028: Research Report on technology, participants, trends, market size and share