HBC209731JosephusTransform题解

别敷衍了所有 算法基础篇 47 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
operations, each operation can be expressed as a pair. . Print the final permutation in one line.numbers from the first number, erase the result number from the ring and write it into the back of the new permutation. numbers from the next number and do the same things again, until all numbers are written into

Roundgod is given a permutation P_{} P ​ of length n_{} n ​ (initially P = {1, 2, cdots, n} P={1,2,⋯,n}) and m_{} m ​ operations, each operation can be expressed as a pair (k, x)_{} (k,x) ​ , which means to do k-{} k−Josephus transform for x_{} x ​ times on permutation P_{} P ​ . Print the final permutation in one line. k-_{} k− ​ Josephus transform is that: firstly list the n_{} n ​ integers in premutation P_{} P ​ in a ring, then count k_{} k ​ numbers from the first number, erase the result number from the ring and write it into the back of the new permutation P'_{} P ′ ​ , then count k_{} k ​ numbers from the next number and do the same things again, until all numbers are written into P'_{} P ′ ​ , which is the result permutation after doing k-{} k−Josephus transform for once on P_{} P ​ . For example, {1, 2, 3, 4, 5}_{} {1,2,3,4,5} ​ will become {3, 1, 5, 2, 4}_{} {3,1,5,2,4} ​ if we do 3-_{} 3− ​ Josephus transform for once on it.

HBC209731JosephusTransform题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC209731JosephusTransform题解