| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11138 | Binary addition |
|
| 11137 | Matrix Transpose |
|
Description
Given a positive integer N, transform it to its unsigned binary representation (e.g. 10 => 1010). Your program needs to output the binary representation of N+1 and the number of carries during the addition in binary representation.
For example, if the input is 11 (in decimal), your program needs to output 1100, because it is the binary representation of 11+1=12. Also your program needs to output 2, because during the binary addition of 11+1, there are two carries generated.
1011 (11 in binary)
+ 0001 (1 in binary)
---------------------------------
1100 (12 in binary)
Input
The input consist of an integer N (0 <= N <= 1024)
Output
The binary representation of N+1 and the number of carries during the binary addition of N+1. Those two numbers are separated by a space. Note that you need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
A matrix A of dimension (N,M) has N*M elements in the format of N rows(橫列) and M columns(直行), and thus each element has a pair of index (i, j), where i is less than N, j is less than M, and both are greater or equal to 0. For example, a matrix A of dimension (2, 3) may look like this:
[ 1 3 5 ]
[ 2 4 6 ]
where the element A(0,1) is 3 and A(1, 0) is 2.
In linear algebra, a transpose of a matrix A, which is AT, is to reflect the A over its main diagonal(主對角線). For each element A(i,j), the new location of the element in the AT is (j,i).
In this problem, a matrix A is given, and you are asked to output AT, which is the transpose of A.
Input
The input consists of 2 parts, which present the marix A:
- The dimentsion of the matrix: two positive integers N and M in one line, and both are not greater than 30.
- The matrix itself: N lines and each line contains M decimal integers that have one 1 digit (0-9). All integers in the a line are seperated by a space.
Output
Output is the matrix AT, which should have M rows. All elements in a row should be seperated by a space, and make sure there is no trailing spaces at the end of each line.