#PCBTAM0000021. Căn phải văn bản theo độ rộng (Right Align Text)
Căn phải văn bản theo độ rộng (Right Align Text)
Right Align Text
Version: Phuoc Hung OJ Extended
Problem Statement
Given string and nonnegative integer , the minimum width of a text field, right-align within the field. If is shorter than , add enough spaces on its left. Otherwise, keep unchanged.
Enclose the field in | characters to make the padding visible. Width is measured in Unicode characters, not UTF-8 bytes.
Input
The first line contains , possibly empty or containing existing spaces. The second contains integer .
Output
Print a line starting and ending with |. The enclosed field has characters and is right-aligned.
Subtasks
- Subtask 1 (100 points): Unicode characters; .
Examples
Example 1
Input
A
4
Output
| A|
Explanation. A has length ; width requires three spaces before it.
Example 2
Input
Đ
3
Output
| Đ|
Explanation. Đ is one Unicode code point; width requires two spaces on its left.
Example 3
Input
abcdef
3
Output
|abcdef|
Explanation. abcdef has length , greater than width , so it is not truncated.