| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10739 | Binary addition |
|
| 10097 | decimal to ternary |
|
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.
Sample Input Download
Sample Output Download
Tags
Discuss
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.