680 - EECS111000_I2P2014_Final Scoreboard

Time

2015/01/12 09:00:00 2015/01/12 13:50:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10409 Problem 1
10410 Problem 2
10411 Problem 3
10412 Problem 4
10413 Problem 5

10409 - Problem 1   

Description

A palindrome (回文) is a word, phrase, number, or other sequence of characters which reads the same backward or forward.
In this problem, you will be given three different strings which consists of characters ‘a’ to ‘z’ and ‘1’to ‘9’. You have to determine whether it is a palindrome or not. If it is a palindrome, output the string. If not, output “NO”.

Example1:
Input : 145abba541
Output : 145abba541 

Example2:
Input: ku6g6uk
Output : ku6g6uk 

Example3:
Input : bhhghh1
Output : NO

Input

The input contains three lines.  Each line is a string which consists of characters ‘a’ to ‘z’ and ‘1’to ‘9’.
The string length is less than or equal to 100, and greater than 1.

Output

If it is a palindrome, output the string. If not, output “NO”.
Note that each answer will be followed by a newline.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10410 - Problem 2   

Description

There are N people numbered 1, 2, ..., N, standing in circle in order. Every kth is going to be executed and only the life of the last remaining person will be saved. 
Josephus is smart enough to choose the position of the last remaining person, thus saving his life. 
Given N and k, please find out the origin position which Josephus stood, and print the execution order. 

For example:
N = 6 and K = 5.
The execution order is 5 4 6 2 3
Josephus stood on position 1.

Input

A line contains two positive integers, N and k.
2 ≤ N ≤ 50, 0 < k ≤ 50

Output

First line is the execution order. Each number is separated by a space, and there is a space at the end.
Second line is the origin position which Josephus stands.
Note that you don’t have to print a newline at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10411 - Problem 3   

Description

The input contains two words and a sentence which contains only lower case letters.
Please find the first word in the sentence and replace it with the second word.

For example, 
sentence : can you can a can as a canner can can a can 
words : can will
output : will you will a will as a canner will will a will 

Input

First line is a sentence which contains only lower case letters. The sentence length is less than or equal to 200 characters. Each word is separated by a space. There is a space at the end of the input sentence. 
Second line is two words separated by a space. Each word length is less than or equal to 20 characters.

Output

The output is the edited sentence. Each word in the output sentence is separated by a space, and there is a space at the end of the output sentence.
Note that you don’t have to print a newline at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10412 - Problem 4   

Description

Given an N by N matrix, output a new (N-2) by (N-2) matrix. Each element of the new matrix corresponds to the maximum value in each 3 by 3 region of the original matrix.

For example, if the original matrix is
10 20 30 90 30
50 60 30 20 50
80 50 70 60 20
90 40 30 20 80
20 30 40 50 90

the new matrix will be
80 90 90
90 70 80
90 70 90

Input

N, 3 ≤ N ≤ 10
An N by N matrix, each element is an integer

Output

A new (N-2) by (N-2) matrix
Use “%d ” to print each element and add a newline at the end of each row.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10413 - Problem 5   

Description

Given two vectors A and B, compute the angle between them in degrees (0~180).
You should use the following equation:
     
where • means dot product, and 
The dot product is the sum of the product of the corresponding components of the two vectors. For example, the dot product of [1,2,3] and [4,5,6] is 32 because 1*4+2*5+3*6 = 32.

After getting the cosine value, you can use arccos to get the angle.
The following is an example of arccos and square root:

#include
#include

int main()
{
    // square root of 9
    printf("%f\n", sqrt(9));

    // arccos of 0.5 in degrees
    printf("%f\n", acos(0.5)*(180/M_PI));
	
    return 0;
}


Furthermore, we represent a high-dimensional sparse vector by using the following format:
dim1:value1 dim2:value2 dim3:value3 … dimN:valueN 0:0
where 0:0 denotes the end of the vector.

An example: The vector [0,5,0,0,9,0,0,33] is an eight-dimensional vector, which can be represented as
2:5 5:9 8:33 0:0
That is, we may omit all dimensions whose values are zero. Such a representation is compact and particularly suitable for high-dimensional sparse vectors.

Note that the dimensions may be presented in arbitrary order. For example, the above vector may also be expressed as
8:33 2:5 5:9 0:0

Input

The input has three lines.
The first line is the dimension of the vectors.
The following two lines contain two vectors of integer values represented in the sparse format.

The usage of memory is limited to 32 MB.
The dimension of the vector is no greater than 231-1, and the N of dimN will not exceed 220.

Output

The angle between the two vectors in degrees (0~180) and a newline at the end.

Note that you should do rounding and output the angle as an integer. 
The following is an example of rounding:

#include
#include

int main()
{
    printf("%f", round(29.59));

    return 0;
}

Sample Input  Download

Sample Output  Download

Tags




Discuss