| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11126 | Binary representation |
|
| 11134 | Swap number |
|
| 11598 | Word rotation |
|
| 11607 | BigNumberMulti |
|
Description
Consider the following program:
#include
#include
int main(void)
{
char str[65] = {0};
int bit[65];
int i, n;
unsigned long long x;
scanf("%64s", str); /* read the input bit string */
n = strlen(str); /* get the length of the string */
i = 0;
x = 0;
while ...
...
If the input string is 1101, the program will print 13. If the input is 100000000000000000000000000000000000001, the output should be 274877906945. Now, your task is to modify the program so that it can do the opposite. That is, given a non-negative decimal number, print its binary representation. For example, if the input is 14, the output should be 1110.
Input
An integer that can be read by scanf using the format "%llu" and can be stored in a variable of type unsigned long long
Output
The binary representation of the input number. Note that you need to print a '\n' at the end of the bit string.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In a shell game, balls with different numbers are hidden beneath identical containers, which are placed in a line. After the containers are shuffled, players need to guess the order of balls.
In this problem, there are five balls, numbered 0-4, and placed under five identical containers. The containers are placed in a straight line, and the initial positions of balls are from 0-4. The problem will then give k swaps of containers. Each swap is represented by a pair of integers, (a,b), meaning the container in position a is swapped with the container in position b. Your program needs to print the final ordering of balls.
For example, k=3, and three swaps are
0 4
2 3
1 2
Initially, the order of balls is: 0 1 2 3 4. After the swap (0,4), the order of balls becomes: 4 1 2 3 0; After the swap (2,3), the order of balls becomes: 4 1 3 2 0; and after the swap (1,2), the order of balls becomes:
4 3 1 2 0. So your program needs to print
4 3 1 2 0
hint:
To swap two numbers, a and b, you can use following code:
int temp;
temp = a;
a = b;
b = temp;
Input
The first line of the input is an integer k (0 < k < 25), which specifies the number of swaps. In the next k lines, each line contains a pair of integers, specifying the two positions to be swapped.
Output
The order of balls after swaps. Note that you do not 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
Arbitrary-precision arithmetic is a common technique in scientific computing.
When we compute some numbers, the sizes of the outcomes are much bigger than the capacities of ‘int’, ‘long long’, and even ‘__int128_t’. Thus, we always use arrays for simulating our implementation.
Now, we give you two positive integers (including 0) which are not over 2000 digits, please output their multiplication.
Input
There is a positive integer T (1 <= T <= 1000). It means that there are T times of operation.
Continuously, there are T rows. In every row, there are two positive integers (including 0), ‘a’ and ‘b’, which are not over 2000 digits. Please compute the ‘a*b’.
Output
According to each multiplication, please output its outcome and print a new line.
When a X-digit number multiplies a Y-digit number, the digits of the outcome will be less than or equal to X+Y. For convenience, suppose that ‘a’ is X-digit, and ‘b’ is Y-digit, the output should be (X+Y)-digit, and please fill the rest of no number part with 0.
For example, you want to compute 11*11, and the outcome is 121. However, the requirement is to output a 4-digit number, so please output 0121.