Codeforces Round #763 (Div. 2) A. Robot Cleaner

该问题描述了一个机器人在矩形房间中清扫的过程。机器人每秒会根据初始设定的移动方向前进,遇到墙壁会反弹。目标是计算机器人到达指定脏点所需的时间。通过判断机器人和脏点的相对位置,确定最少步数。
摘要由CSDN通过智能技术生成

题目链接:Problem - A - Codeforces

A robot cleaner is placed on the floor of a rectangle room, surrounded by walls. The floor consists of nn rows and mm columns. The rows of the floor are numbered from 1 to n from top to bottom, and columns of the floor are numbered from 1 to m from left to right. The cell on the intersection of the rr-th row and the cc-th column is denoted as (r,c). The initial position of the robot is (rb,cb).

In one second, the robot moves by drdr rows and dcdc columns, that is, after one second, the robot moves from the cell (r,c) to (r+dr,c+dc). Initially dr=1, dc=1. If there is a vertical wall (the left or the right walls) in the movement direction, dcdc is reflected before the movement, so the new value of dcdc is −dc. And if there is a horizontal wall (the upper or lower walls), dr is reflected before the movement, so

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值