1053 - I2P CS 2016 Fall Lee Midterm 1 Scoreboard

Time

2016/10/31 15:45:00 2016/10/31 17:50:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11173 Adding Decimals
11179 Interval Overlap
11172 Spiral Text - The Main Diagonal

11173 - Adding Decimals   

Description

Adding decimal (十進位制) numbers seems like a piece of cake for human beings. In this problem, 2 positive integers, A and B, are given, and you are asked to output the sum to these integers, and the number of carries while adding.

A carry happends when the result of addition of certain digit is greater than 9. In that case, the higher digit will receive the additinal 1 when adding. See the following case:

Carry     1     1 1 1
A           7 1 2 3 4 5
B           7 8 6 6 8 5 
      +)________________
Sum       1 4 9 9 0 3 0

So, the sum is 1499030 and the number of carries is 4.

Input

2 positive integers, A and B, are given in a line and seperated by a space. Each of the integers is smaller than 109, which means it will not execceed 999,999,999.

Output

Print the sum and number of carries in a line, and seperate them with a space. And print a new line ('\n') character at the end of the your answer.

Sample Input  Download

Sample Output  Download

Tags

I2P CS 2016 Lee Mid1



Discuss




11179 - Interval Overlap   

Description

In this problem, we define an interval [a..b] as a continuous one-dimensional area form number a to b.

you are asked to calculate the number of interval pairs that overlap each other among a set of given intervals.  All intervals are located in a number line, and all their endpoints are integers.

Input

The first line contains one number N, where 2 <= N <= 256, standing for the number of given intervals.

Each of the following N lines describes an interval and has 2 integers separated by space, representing

  1. the coordinate of the left vertex
  2. the coordinate of the right vertex

For each interval, you may assume the coordinate of the left vertex is smaller than the one of the right vertex.

Notice that each of the 2 numbers is representable by an int type in C language.

Output

The output should contain only one number, representing the number of interval pairs that intersect to each other.

Notice that if the overlapping part is of zero length, then the pair should NOT count.

Sample Input  Download

Sample Output  Download

Tags

I2P CS 2016 Lee Mid1



Discuss




11172 - Spiral Text - The Main Diagonal   

Description

In this problem, you are asked to rearrange a given text in a square and output its main diagonal (主對角線) in the "spiral form".

A square is an area with NxN grids. For a given text with length NxN, you put the first character in the upper-left grid. Then, you put the following N-1 characters to the right of the previous one, and you will reach the right border of the square. Any time you can't find an empty place on current direction, you turn "right" and place the next character untile you finish placing all characters and reach the center of the square.

The case below shows the result of a text "0123456789ABCDEF" in a 4x4 square:

0123
BCD4
AFE5
9876

And in this case, you should print "0CE6" as the answer.
 
Hint:
There are at least 2 strategies to solve this question. The first one is placing these texts in a square, while the other one is trying to find rules to fetch the main diagonal directly from the original text. Feel free to draw some cases on the paper we provided.

Input

There are 2 lines for the input. The first shows the integer N (1<= N <= 16) denotes the size of the edges of the square. The following line is a text with exactly NxN characters. There might be alphabets, numbers and spaces in the text.

If you use getchar() to fetch characters in the text, make sure you handle the "new line" ('\n') character in the first line properly.

Output

Print the characters in the main diagonal in a line. There should be exactly N characters folowing a new line ('\n') symbol.

Sample Input  Download

Sample Output  Download

Tags

I2P CS 2016 Lee Mid1



Discuss