当前位置:网站首页>L1-019 who falls first (Lua)
L1-019 who falls first (Lua)
2022-07-07 19:13:00 【Just be interesting】
subject
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 them, shouting is the number , A stroke is a number drawn out , 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
1
Code
function ReadValue(str)
local arr = {
}
local idx = 1
for i = 1, #str do
if str:sub(i,i) == " " then
table.insert(arr, tonumber(str:sub(idx, i - 1)))
idx = i + 1
end
end
table.insert(arr, tonumber(str:sub(idx)))
return arr[1], arr[2], arr[3], arr[4]
end
local str = io.read()
local x1, x2 = 0, 0
for i = 1, #str do
if str:sub(i,i) == " " then
x1 = tonumber(str:sub(1, i - 1))
x2 = tonumber(str:sub(i + 1))
break
end
end
local n = io.read()
local d1, d2 = 0, 0
for i = 1, n do
local a1, a2, b1, b2 = ReadValue(io.read())
local ans = a1 + b1
if a2 == ans and b2 ~= ans then
d1 = d1 + 1
else
if a2 ~= ans and b2 == ans then
d2 = d2 + 1
end
end
if d1 > x1 then
print("A")
print(d2)
break
end
if d2 > x2 then
print("B")
print(d1)
break
end
end
边栏推荐
- App capture of charles+postern
- Flipping Game(枚举)
- 抢占周杰伦
- Teach your sister to write the message queue hand in hand
- [information security laws and regulations] review
- [Tawang methodology] Tawang 3W consumption strategy - U & a research method
- Zhong Xuegao wants to remain innocent in the world
- SlashData开发者工具榜首等你而定!!!
- 基于图像和激光的多模态点云融合与视觉定位
- 伺服力矩控制模式下的力矩目标值(fTorque)计算
猜你喜欢
面试唯品会实习测试岗、抖音实习测试岗【真实投稿】
学习open62541 --- [67] 添加自定义Enum并显示名字
Learn open62541 -- [67] add custom enum and display name
2022.07.05
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
How to choose the appropriate automated testing tools?
Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
博睿数据入选《2022爱分析 · IT运维厂商全景报告》
App capture of charles+drony
随机推荐
Flipping Game(枚举)
从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
Charles+Postern的APP抓包
How to estimate the value of "not selling pens" Chenguang?
Interview vipshop internship testing post, Tiktok internship testing post [true submission]
Cadre de validation des données Apache bval réutilisé
Rules for filling in volunteers for college entrance examination
Numpy——2.数组的形状
The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t
3.关于cookie
Do you know all four common cache modes?
testing and SQA_ Dynamic white box test [easy to understand]
Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society
Desci: is decentralized science the new trend of Web3.0?
Big Ben (Lua)
cmd命令进入MySQL时报服务名或者命令错误(傻瓜式教学)
Basic operation of chain binary tree (implemented in C language)
Will low code help enterprises' digital transformation make programmers unemployed?