afterward

导航

 

 

 

当想出来只是求余的问题的时候就不难了。其实都不想发的。

View Code
#include<iostream>
#include<stdio.h>
using namespace std;
int a[53],b[53];
int main(){
    int t,n,l,r,i,j;
        int s,w;
    cin>>t;
    int d=0;
    while(t--)
    { 
        for(i=0;i<52;i++)
            cin>>a[i];
        cin>>n>>l>>r;
            s=r-l+1;
            //cout<<"s:"<<s<<endl;
        i=r;
        for(j=0;j<r;j++)
            b[j]=a[--i];//找出B中第n个s
        //cout<<"b[i]:";
        //for(j=0;j<r;j++) cout<<b[j]<<" ";
        //cout<<endl;
                w=(n%r*s)%r-1;
        // cout<<"w:"<<w<<endl;

    printf("Case #%d: ",++d);
        int ss=0;
        for(i=w;i>-1;i--)
            {
                ss++;
                if(ss==52) cout<<b[i]<<endl;
                else cout<<b[i]<<" ";
            }

        for(i=r-1;i>w;i--)
        {    
            ss++;
            if(ss==52) cout<<b[i]<<endl;
            else  cout<<b[i]<<" ";
        }
        for(i=r;i<52;i++)
            {    ss++;
                if(ss==52) cout<<a[i]<<endl;
                else cout<<a[i]<<" ";
        }
    
     
    }
   return 0;
}

但是这是航电上比赛有史以来我提交过的第一题,算是自我鼓励把,放在这里自我安慰,以后还要写代码,写自己的代码。

 

Card

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10    Accepted Submission(s): 9


Problem Description
Bearchild 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?
 

Input
First 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)
 
Output
For 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 befor every number.
 
Sample Input
1
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 26 4 44 17 39 38 15 14 25 16 29 20 21 45 11 34
902908328 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

posted on 2012-08-09 20:02  afterward  阅读(245)  评论(0编辑  收藏  举报