| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11154 | Swap Matrix row |
|
| 11127 | Binary representation&sum |
|
Description
Given a 5*5 matrix, your job is to swap two specific rows i and j (where 0 <= i,j < 5) several times.
For example:
Consider a matrix,
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
and the two rows (i,j) = (1,3).
After swap, the matrix will become
1 2 3 4 5
16 17 18 19 20
11 12 13 14 15
6 7 8 9 10
21 22 23 24 25
Input
The input consists of two parts.
The first part contains a 5*5 matrix.
The first line of the second part contains an integer N ( 0 < N <= 5 ), indicating the number of swaps.
In the next N lines, each contains 2 integers i,j ( 0 <= i,j < 5 ).
Hint:
You can use the following code to read input.
i=0;
while(i<5) {
j=0;
while(j<5) {
scanf("%d",&matrix[i][j]);
j++;
}
i++;
}
scanf("%d",×);
while(times>0){
scanf("%d%d",&input[0],&input[1]);
…
times--;
…
Output
The final matrix.
Note that you need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Problem 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 do not need to print ‘\n’ at the end of the output.