2022-2023年Bebras挑战练习题-Nuts and Bolts(螺母和螺栓)

At the Beaver Construction factory, Benoit works at the nut and bolt  assembly line.在比弗建筑工厂,贝努瓦在螺母和螺栓装配线上工作。

2022-2023年Bebras挑战练习题-Nuts and Bolts(螺母和螺栓)

His job description is as follows:他的工作职责如下:

  • Stand at one end of a conveyor belt, which brings a line of nuts and bolts.站在传送带的一端,传送带上有一排螺母和螺栓。
  • Take each element, either a nut or a bolt, off the conveyor belt.把传送带上的每个零件,不管是螺母还是螺栓,都取下来。
  • Put the nuts from the conveyor belt in the red bucket.把传送带上的坚果放进红色的桶里。
  • Attach any bolt, taken from the conveyor belt, to a nut from the red bucket and place the assembled part onto the table behind you.从传送带上取下任意一个螺栓,与红色桶里的一个螺母拧在一起,然后把拧好的部件放到你身后的桌子上。

However, things can go wrong for Benoit in two different ways:然而,对于贝努瓦来说,事情可能会以两种不同的方式出错:

  1. When Benoit takes a bolt from the conveyor belt there may not be a nut in the bucket.当贝努瓦从传送带上取下一颗螺栓时,桶里可能没有螺母。
  2. There may be no more nuts or bolts on the conveyor belt but there are still nuts in the bucket.传送带上可能已经没有螺母或螺栓了,但桶里还有螺母。

Question: 问题:

Which sequence of nuts and bolts, when processed from left-to-right, will not cause things to go wrong for Benoit?从左至右依次加工哪一组螺母和螺栓,才不会让贝努瓦出错?

A.

B.

C.

D.

   

 

 

 

 

Explanation 解释

Answer: 答案:

C.

Explanation: 解释:

We can keep track of the state of the bucket and conveyor belt from left-to-right:我们可以从左到右跟踪料斗和传送带的状态:

  • N =
  • B =
Bucket Conveyor Belt
empty N B N N B N N B B B
N B N N B N N B B B
empty N N B N N B B B
N N B N N B B B
N N B N N B B B
N N N B B B
N N N B B B
N N N B B B
N N B B
N B
empty empty

Looking at the other answers:看看其他答案:

will go wrong after N B B, since there will be no nut in the bucket when the second B is encountered.在执行了 N 次 B B 操作之后将会出错,因为在遇到第二个 B 时桶里将没有坚果了。

will go wrong after N N B N N B B B B, since there will be no nut in the bucket when the fifth B is encountered: notice there are only 4 N's before this B.在遇到第 5 个 B 时将会出错,因为此时桶里已没有坚果了:请注意,在这个 B 之前只有 4 个 N。

will go wrong after the entire sequence is processed, since there will be two nuts in the bucket, since there are 6 N's and 4 B's.在整个序列处理完毕后会出现错误,因为桶里会有两个螺母,因为有 6 个 N 和 4 个 B。

点击右侧文字,可获得更多在线练习题资源:>>> Bebras在线水平测试

Bebras新赛季备赛已开启,扫码领取Bebras真题资料⇓

欢迎咨询【Bebras专业辅导课程】

(Bebras每日一练部分展示)

在线客服
微信咨询