Bronze-2017Dec-Bovine Shuffle

5只牛(N=5), 根据a1=1,a2=3,a3=4,a4=5,a5=2的换位顺序,经过三次变化后得到的顺序是。1234567(第一只牛的id)222222,3333333,4444444,5555555(第五只牛的id)那么直接在数组中回滚三次,找回原来的位置就好。认真模拟下,难度不打,主要是理解题目意思难。这道题理解起来是麻烦的,考验英语阅读了。直接用样例来解释就是,问我们开始洗牌前,牛的顺序是什么?...
摘要由CSDN通过智能技术生成

Convinced that happy cows generate more milk, Farmer John has installed a giant disco ball in his barn and plans to teach his cows to dance!

Looking up popular cow dances, Farmer John decides to teach his cows the "Bovine Shuffle". The Bovine Shuffle consists of his NN cows (1≤N≤1001≤N≤100) lining up in a row in some order, then performing three "shuffles" in a row, after which they will be lined up in some possibly different order. To make it easier for his cows to locate themselves, Farmer John marks the locations for his line of cows with positions 1…N1…N, so the first cow in the lineup will be in position 1, the next in position 2, and so on, up to position NN.

A shuffle is described with N numbers, a1…aNa1…aN, where the cow in position ii moves to position ai during the shuffle (and so, each ai  is in the range 1…N1…N). Every cow moves to its new location during the shuffle. Fortunately, all the  ai's are distinct, so no two cows try to move

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xy404chef

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值