当前位置:网站首页>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
边栏推荐
- 如何选择合适的自动化测试工具?
- 博睿数据入选《2022爱分析 · IT运维厂商全景报告》
- ES6 note 1
- Differences between rip and OSPF and configuration commands
- [tpm2.0 principle and Application guide] Chapter 9, 10 and 11
- PTA 1102 teaching Super Champion volume
- 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
- Former richest man, addicted to farming
- Static routing configuration
- gsap动画库
猜你喜欢

Version 2.0 of tapdata, the open source live data platform, has been released

SlashData开发者工具榜首等你而定!!!

App capture of charles+postern

In 2021, the national average salary was released. Have you reached the standard?

Micro service remote debug, nocalhost + rainbow micro service development second bullet

微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹

SD_ DATA_ RECEIVE_ SHIFT_ REGISTER

DeSci:去中心化科学是Web3.0的新趋势?

直播预约通道开启!解锁音视频应用快速上线的秘诀

In the first half of 2022, I found 10 books that have been passed around by my circle of friends
随机推荐
【剑指 Offer】59 - I. 滑动窗口的最大值
Hongmeng smart home [1.0]
Numpy——2.数组的形状
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
Save the memory of the model! Meta & UC Berkeley proposed memvit. The modeling time support is 30 times longer than the existing model, and the calculation amount is only increased by 4.5%
PTA 1101 B是A的多少倍
POJ 1182 :食物链(并查集)[通俗易懂]
[Tawang methodology] Tawang 3W consumption strategy - U & a research method
ES6笔记一
初识缓存以及ehcache初体验「建议收藏」
LeetCode 890(C#)
App capture of charles+drony
In 2021, the national average salary was released. Have you reached the standard?
Zhong Xuegao wants to remain innocent in the world
Initial experience of cache and ehcache "suggestions collection"
Classification and application of enterprise MES Manufacturing Execution System
二叉树的基本概念和性质
Do you know all four common cache modes?
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
链式二叉树的基本操作(C语言实现)