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;
}