HDU 4350 card (Mathematics)

Source: Internet
Author: User
Card

Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 894 accepted submission (s): 518


Problem descriptionbearchild is playing a card game with himself. But first of all, he needs to shuffle the cards. His strategy is very simple: After putting all the cards into a single stack,
He takes out some cards in the middle, from the L-th to the R-th when counting from top to bottom, aggressive, and puts them on the top. He repeats this action again
And again for n times, and then he regards his cards as shuffled.

Given L, R and N, and the initial card stack, can you tell us what will the card stack be like after getting shuffled?


Inputfirst line contains an integer T (1 <= T <= 1000), which is the test cases.
For each test case, first line contains 52 numbers (all numbers are distinct and between 1 and 52), which is the card number of the stack, from top to bottom.
Then comes three numbers, they are N, L and R as described. (0 <= n <= 109, 1 <= L <= r <= 52)


Outputfor each test case, output "case # X:", X is the test number, followed by 52 numbers, which is the card number from the top to bottom. note that you shoshould output one and only
One blank before every number.


Sample Input

113 2 10 50 1 28 37 32 30 46 19 47 33 41 24 24 27 42 49 18 9 48 23 35 31 8 7 12 6 5 3 22 43 36 51 40 26 4 44 17 39 38 15 14 25 16 29 20 21 45 11 34902908328 38 50


Sample output

 
Case #1: 26 4 44 17 39 38 15 14 16 29 20 21 45 13 2 10 50 1 28 37 32 30 46 19 47 33 41 24 27 42 49 18 9 48 23 35 31 8 7 12 6 5 3 22 43 36 51 40 11 34


Authorelfness @ uestc_oblivion


Source2012 multi-university training contest 6


Recommendzhuyuanchen520

# Include <iostream> # include <stdio. h> # include <string. h> using namespace STD; int rec [100]; int main () {int T, I, J, K = 0; long TMP; scanf ("% d ", & T); long a, B, c; while (t --) {k ++; for (I = 1; I <= 52; I ++) scanf ("% d", & rec [I]); CIN> A> B> C; TMP = A * (c-B + 1 ); TMP % = C; for (I = 1; I <= C; I ++) if (I + TMP) % C = 1) break; printf ("case # % d:", k); For (j = I; j <= C; j ++) printf ("% d ", REC [J]); For (j = 1; j <I; j ++) printf ("% d", REC [J]); for (I = C + 1; I <= 52; I ++) printf ("% d", REC [I]); printf ("\ n ");} return 0 ;}

This is a simple loop, and there is no need to simulate it at all. Just find the first number before C and output it to C, then, output the final output part after C from the first one. The question is relatively simple!

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.