| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10097 | decimal to ternary |
|
| 11126 | Binary representation |
|
| 11598 | Word rotation |
|
Description
Input two positive integers, X and Y. The task is to translate the decimal number X into Y digits ternary (三進位) number, and output the Y digits ternary number.
X is smaller than 1000 and Y is smaller than 8.
Input
Two positive integers, X and Y. X is smaller than 1000 and Y is smaller than 8.
Output
The Y digits ternary representation of the input number X.
Note that you need to print a '\n' at the end of the bit string.
Sample Input Download
Sample Output Download
Tags
Discuss
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
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.