HUNAN UNIVERSITY ACM/ICPC Judge Online_Problem 10039_Magician

Magician
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 495, Accepted users: 471
Problem 10039 : No special judgement
Problem description
Denis Mednoepole is a famous magician. For example, he can read spectators' minds and tell the random number that a spectator has got by means of Denis's magic machine. Any spectator can check this: he or she just rotates the wheel of the machine and looks at the 10-digit number that has appeared in the window of the machine. Within two seconds Denis will read the spectator's mind and tell the number. You must write a program that will tell this number even faster - within one second. You need to know that the magic machine has a wheel with N digits written along the edge of the wheel without spaces between them. All digits are of the same width. The window is 10 digits wide, so it shows 10 successive digits. Each time the wheel turns "one digit" an audible click is produced. So you know how many clicks Denis Mednoepole heard while the spectator was rotating the wheel.
Input
There wil be several test cases. For each test case, the first line contains two integers separated with a space, N and M. Here N (10 ≤ N ≤ 1000) is the number of the digits written on the wheel, and M (1 ≤ M ≤ 32767) is the number of clicks produced by the wheel. The next N lines contain all the digits written on the wheel, one digit per line. The digits are given in the clockwise order. The first ten digits correspond to the number visible in the window before the rotation. The wheel can be rotated only counter-clockwise, thus after one click the first digit will go out of site and the 11-th digit will become visible.
Output
Write the number that will appear in the window of the magic machine after the rotation a line for each test case.
Sample Input
12 7
1
2
3
4
5
6
7
8
9
0
7
7
10 12
4
5
7
1
2
4
2
3
9
7
Sample Output
8907712345
7124239745
Problem Source
HNU 1'st Contest

CODE

/*

  Name: 10039_Magician

  Copyright:  yangchun's

  Author:  yangchun

  Date:  19-06-08 19:58

  Description:  HUNAN UNIVERSITY ACM/ICPC Judge Online_Problem 10039_Magician

*/



#include <algorithm>



int main()

{

    //freopen("in.txt","r",stdin);

    //freopen("out.txt","w",stdout);

    

    int i,j,n,m,num[1001];

    

    while(scanf("%d%d",&n,&m)!=EOF)

    {

        memset(num,0,sizeof(num));

        

        for(i=1; i<=n; i++)

            scanf("%d",num+i);

            

        j = m%n;

        for(i=1; i<=10; i++)

        {

            if(j == n)  j=0;

            printf("%d",num[j+1]);

            j++;

        }

        printf("/n");

    }

    

    return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值