HUNAN UNIVERSITY ACM/ICPC Judge Online_Problem 10042_SpinLock

SpinLock
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 358, Accepted users: 347
Problem 10042 : No special judgement
Problem description
Simulate a locked spinner puzzle.
A locked spinner puzzle is a puzzle where you can only change wheels in groups. It is a common puzzle to achieve some value on the spinners with by only changing them in the allowed groups.
Assume a row of D numbered wheels, such as what is found on a combination lock on a briefcase.
 
(example: wheels of a briefcase lock)
Each wheel will be labeled sequentially with the digits 0 through 9.  The initial state of the wheels is part of the problem specification.
Below this are a series of B buttons with labels that are D digits long. For example, D may be 4 and the labels are 1000 1200 1002 0111 and 0100. Pressing the button labeled 1000 moves the first wheel once, but leaves the others alone, while pressing the button labeled 1002 moves the first wheel once and the fourth wheel twice, leaving the center button unchanged.
Your task is to simulate such a locked spinner puzzle, providing the final readout of the wheels.
Input
The input to your program will be several spinner puzzles. Each puzzle will be D digits (at most 10) representing the starting positions of the wheels. Following this, each line will have the button label for which button is pressed next. The end of each spinner puzzle will be marked with the character ‘x’ alone on a single line. End of the input file will be marked with the character ‘z’.
Output
The output file should print the final positions of each spinner puzzle’s wheels. Provide the output header “Spinlock Results” on the first line. Each puzzle follows on a separate line, formatted as below.
Sample Input
0001
1003
0206
0034
1111
1003
x
91234567
12340051
33402401
x
z
Sample Output
Spinlock Results
3348
36976919
Problem Source
HNU 1'st Contest

CODE

/*

  Name:  10042_SpinLock

  Copyright:  yangchun's

  Author:  yangchun

  Date:  22-06-08 18:10

  Description:  HUNAN UNIVERSITY ACM/ICPC Judge Online_Problem 10042_SpinLock

*/



#include <algorithm>

#include <iostream>

#include <time.h>



using namespace std;



int main()

{

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

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

    

    int i, D = 0, num[10] = {0}, _num = 0;

    char labels[10];

    

    while(scanf("%s",labels))

    {

        if(labels[0] == 'z')    break;

        else if(labels[0] == 'x')

        {

             if(_num == 0)    printf("Spinlock Results/n");

             for(i=0; i<D; i++)

                 printf("%d",num[i]%10);

             printf("/n");

             

             D=0, _num++;

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

             continue; 

        }

        else if(D == 0)    D = strlen(labels);

        

        for(i=0; i<D; i++)

            num[i] += labels[i]-'0';

    }

    

    //printf("time = %ld ms/n",clock());

    

    return 0;

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值