HDU 4350 Card(數學)

來源:互聯網
上載者: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, inclusive, 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 should 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 52 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 25 16 29 20 21 45 13 2 10 50 1 28 37 32 30 46 19 47 33 41 24 52 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 long tmp;scanf("%d",&t);long 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;}

這個題目比較簡單了,就是一個簡單的迴圈,根本就不需要什麼類比來實現,只要找到C前面的第一個應該輸出的編號,輸出到C,然後從第一個開始輸出最後輸出C後面部分的就OK 了,題目比較簡單!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.