20th codeforces competition ends #276Div2

Source: Internet
Author: User
Howmanyspecificordersdoyouknow? Ascendingorder, descendingorder, orderofascendinglength, orderofascendingpolarangle... Letshavealookatanotherspecificorder: d-sorting.Thissortingisappliedtothestringsoflengt

How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... let's have a look at another specific order: d-sorting. this sorting is applied to the strings of lengt

How many specific orders do you know? Ascending order, descending order, order of ascending length, order of ascending polar angle... Let's have a look at another specific order:D-Sorting. This sorting is applied to the strings of length at leastD, WhereDIs some positive integer. the characters of the string are sorted in following manner: first come all the 0-th characters of the initial string, then the 1-st ones, then the 2-nd ones and so on, in the end go all (D? -? 1)-th characters of the initial string. ByI-Th characters we mean all the character whose positions are exactlyIModuloD. If two characters stand on the positions with the same remainder of integer pisionD, Their relative order after the sorting shouldn't be changed. The string is zero-indexed. For example, for string 'qwerty ':

Its 1-sorting is the string 'qwerty '(all characters stand on 0 positions ),

Its 2-sorting is the string 'qetwry' (characters 'Q', 'E' and 'T' stand on 0 positions and characters 'w ', 'R' and 'y' are on 1 positions ),

Its 3-sorting is the string 'qrwtey' (characters 'Q' and 'R' stand on 0 positions, characters 'W' and 't'stand on 1 positions and characters 'E' and 'y' stand on 2 positions ),

Its 4-sorting is the string 'qtwyer ',

Its 5-sorting is the string 'qywert '.

You are given stringSOf lengthNAndMShuffling operations of this string. Each shuffling operation accepts two integer argumentsKAndDAnd transforms stringSAs follows. For eachIFrom 0N? -?KIn the increasing order we apply the operationD-Sorting to the substringS[I..I? +?K? -? 1]. HereS[A..B] Represents a substring that consists of characters on positions fromAToBIntrusive.

After each shuffling operation you need to print stringS.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.