题解 | 小红的环形数组

小红的环形数组

https://www.nowcoder.com/practice/2094caa98e9c40fa8da8436ee7e232c6

A = list(map(int, input().split(" ")))
n = A[0]
o = A[1]
nums = list(map(int, input().split(" ")))
for i in range(o):
    operate = input().split(" ")
    start = int(operate[0])
    step = int(operate[2])
    if operate[1] == "R":
        num = (step + start - 1)%n
    elif operate[1] == "L":
        num = (start - step - 1)%n
    print(nums[num])

全部评论

相关推荐

牛客38347925...:9,2学生暑期实习失利开始投小厂,给这群人整自信了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务