当前位置:网站首页>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
边栏推荐
- [sword finger offer] 59 - I. maximum value of sliding window
- 【塔望方法论】塔望3W消费战略 - U&A研究法
- 我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
- Zhong Xuegao wants to remain innocent in the world
- Cloud security daily 220707: Cisco Expressway series and telepresence video communication server have found remote attack vulnerabilities and need to be upgraded as soon as possible
- Nat address translation
- 国内的软件测试会受到偏见吗
- 脑洞从何而来?加州大学最新研究:有创造力的人神经连接会「抄近道」
- 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%
- 鸿蒙智能家居【1.0】
猜你喜欢
Version 2.0 of tapdata, the open source live data platform, has been released
博睿数据入选《2022爱分析 · IT运维厂商全景报告》
[unity shader] insert pass to realize the X-ray perspective effect of model occlusion
RISCV64
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
基于图像和激光的多模态点云融合与视觉定位
Kirk borne's selection of learning resources this week [click the title to download directly]
Multimodal point cloud fusion and visual location based on image and laser
The top of slashdata developer tool is up to you!!!
随机推荐
Standard ACL and extended ACL
[Base64 notes] [suggestions collection]
Hutool - lightweight DB operation solution
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
10 schemes to ensure interface data security
微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
The moveposition function of rigidbody2d of unity2d solves the problem of people or screen jitter when moving
嵌入式面试题(算法部分)
數據驗證框架 Apache BVal 再使用
完整的电商系统
初识缓存以及ehcache初体验「建议收藏」
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
Cloud security daily 220707: Cisco Expressway series and telepresence video communication server have found remote attack vulnerabilities and need to be upgraded as soon as possible
Do you know all four common cache modes?
Will low code help enterprises' digital transformation make programmers unemployed?
"Decryption" Huawei machine vision Corps: Huawei is moving up and the industry is moving forward
Basic operation of chain binary tree (implemented in C language)
DeSci:去中心化科学是Web3.0的新趋势?
Numpy——2.数组的形状