| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11154 | Swap Matrix row |
|
| 11598 | Word rotation |
|
| 11624 | Bit reverse |
|
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
Given a string with length L < 1001 and only containing capital letters, lower letters and digits, please output the result of rotating the word for one time, and repeat doing so for L times.
Suppose the original string is ab1cde , after rotating for one time, the result will be b1cdea.
That is, the operator of rotating for one time is to move the first letter of the string to the tail of the string.
Input
There is only one line in the input, which is a string only containing capital letters, lower letters and digits.
The length of the string L < 1001.
Output
Output the result of rotating the word for one time, and repeat doing so for L times. The last line is the original string. Remember to print the endline character.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Nymphia is reading an eight-digit binary number consisting of 0s and 1s through a mirror. Because right and left are reversed in the mirror, Nymphia gets a wrong number when she directly converts the binary number to the corresponding decimal number according to the order she saw in the mirror. Can you help Nymphia correct this wrong number?
Input
Only a number N, 0<=N<=2^8
Output
Please output a decimal number with correct interpretation, and be sure to put ‘\n’ at the end.