1073 - I2P(I)2016_Yang_Lab4 Scoreboard

Time

2016/11/17 13:30:00 2016/11/17 14:50:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11200 Tower of Hanoi
11214 Find Palindrome

11200 - Tower of Hanoi   

Description

The Tower of Hanoi is a mathematical game puzzle. It consists of three rods, which are A, B and C. The puzzle starts with disks in ascending order of size on rod A, the smallest at the top.

The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:

1.   Only one disk can be moved at a time.

2.   Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.

3.   No disk may be placed on top of a smaller disk.

Write a program to simulate the moves of the disks. Print the number of disk which is moved in each step.

 

For example, if n = 3, the moves of each steps are:

move disk 1 from rod A to rod C
move disk 2 from rod A to rod B
move disk 1 from rod C to rod B
move disk 3 from rod A to rod C
move disk 1 from rod B to rod A
move disk 2 from rod B to rod C
move disk 1 from rod A to rod C


You should print out:

1
2
1
3
1
2
1

HINT : You can modify this sample code and implement the function 'hanoi'

#include <stdio.h>
void hanoi(int n, char A, char B, char C);

int main(){
    int n;
    scanf("%d", &n);
    hanoi(n, 'A', 'B', 'C');
    return 0;
}

Input

An integer n (0<n<20), which means the number of disk.

Output

Print out the number of disk which is moved in each step, and there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11214 - Find Palindrome   

Description

Palindrome is a string that is identical to its reverse, like "level" or "aa". Given a string, find if there is a palindrome with length greater than or equal to 2 in the string.

 

Input

The first line of the input is an integer N, indicating the number of test cases.

In the next N lines, each contains a string. The length of each string is less than 1000. The number of test cases is less than or equal to 10.

Output

In each test case, output “Yes” if there is a palindrome with length greater than or equal to 2 in the input. Otherwise, output “No”. 

Sample Input  Download

Sample Output  Download

Tags




Discuss