| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10741 | The Encoded Word |
|
| 11111 | Encode number |
|
Description
The input is a three-digit integer N that consists of digits 1-9 except 0. The task is to use the following rule to encode the input number:
First digit => even: 'A', odd: 'B'
Second digit => even: 'C', odd: 'D'
Third digit => even: 'E', odd: 'F'
For example, if the input is 489, the output should be ACF because 4 is even, 8 is even, and 9 is odd.
Hints:
1. Given an integer x and two values M and N, we can use the following equation to select one of M and N according to x being even or odd.
y = (x%2)*M + ((x+1)%2)*N;
That is, if x is odd, y will have value M; if x is even, y will get value N.
2. Characters like 'A', 'B', 'C' are constant values. We can use them in computations such as 0*'A' + 1*'B' or 'D' - 'A'.
Input
A three-digit integer consisting of only 1-9 but not 0
Output
The encoded three-letter word.
Note that you do not need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Suppose that we have an encoding scheme defined by the following mapping:
1->'A', 2->'B', 3->'C', ..., 9->'I'
Given a three-digit number N as the input, use the above mapping to encode N.
Input
A three-digit integer N
Output
The encoding result
Note that you do not need to print ‘\n’ at the end of the output.