2435 - I2P(I)2021_Hu_Hw10 Scoreboard

Time

2021/11/25 16:00:00 2021/12/06 18:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13370 Bender and the Haunted Mansion
13371 Merge Sorting
13372 Pointer Magic

13370 - Bender and the Haunted Mansion   

Description

After the death of his uncle, Bender inherited the his large mansion but what he does not know is that the mansion is haunted by robot ghosts. While he was staying a night with his friends, he saw the scariest image imaginable:

Once he saw that horrific sight he knew that he must use the power of programming to reprogram his machine brain to understand what it meant. 

When reading a set of numbers, Bender will know that the base of that number is. The set of numbers also only come in 8 digits and the numbers can range from 0 to 15, with A equal to 10, B equal to 11, and so on. The base of the number on the other hand can range from 2 to 16 (binary and hexadecimal).

In the set of digits, no number will exceed the base, so when the base is 8, the highest possible number is 7 but when the base is 16, the highest possible number is 15.

All the program has to do is convert all the given digits to a decimal number.

For an example, the number  set, 10111001, with a base of 2 is calculated like this:

2^7 * 1 + 2^6 * 0 + 2^5 * 1 + 2^4 * 1 + 2^3 * 1 + 2^2 * 0 + 2^1 * 0 + 2^0 * 1 = 185

Input

integer M which represents the number's base 

a string of exactly 8 integers

Output

the value of the 8 decimal in base 10 form followed by a newline

Sample Input  Download

Sample Output  Download

Tags




Discuss




13371 - Merge Sorting   

Description

Merge Sorting is an essential way to sort arrays. Merge Sort is a divide and conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. 

The following is a pseudocode for the algorithm:

 

MergeSort(arr[], l,  r)
If r > l
     1. Find the middle point to divide the array into two halves:  
             middle m = l+ (r-l)/2
     2. Call mergeSort for first half:   
             Call mergeSort(arr, l, m)
     3. Call mergeSort for second half:
             Call mergeSort(arr, m+1, r)
     4. Merge the two halves sorted in step 2 and 3:
             Call merge(arr, l, m, r)

Please implement a function to execute the merge sort algorithm.

You will be given an integer M which corresponds to the size of the array to be sorted, followed by M number of integers which are the contents of the array.

Input

Integer M (1 <= M <= 100 000)

M numbr of integers. (all integers will be able to fit in an int variable)

Output

The contents of the array followed by a newline character.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13371.c

Partial Judge Header

13371.h

Tags




Discuss




13372 - Pointer Magic   

Description

After getting rejected by a girl, Morty realizes that he does not need a girlfriend, what he needs is to study programming. He already understands the basics of C programming but is struggling to understand pointers.

To help him understand better, Morty decides to practice making functions to change values of 2 malloced arrays. The functions he made are:

Swap, which takes in 2 characters and 2 integers and uses them for coordinates for the integers that needs to be swapped. (A B 1 2 means to swap the values of A[1] and B[2])  

Switch, swaps all the values of array A and array B

Replace, which takes in 1 character and 2 integers, the first 2 are used for coordinates whereas the last integer is used for the new value.(A 1 100 means replace the value of A[1] to 100)

Stop, which stops the program and prints out the contents of both arrays.

Once Morty finishes this program suddenly the girl he rejected changed her mind, so in order to help you get a girlfriend/boyfriend, Morty wants you to make this program.

This is a partial judge program.

Input

integer M, the size of both arrays

M*2 number of integers which are the values of both arrays

A number of Commands:

Swap (2 characters and 2 integers)

Switch

Replace (1 character and 2 integers)

Stop (Stop the program and print the arrays)

 

Output

The contents of both arrays followed by a newline

Sample Input  Download

Sample Output  Download

Partial Judge Code

13372.c

Partial Judge Header

13372.h

Tags




Discuss